Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Glad I could help. The perlmod Perl documentation is probably the best single source of information on your question. It does talk about package semantics, but pay particular attention to the "BEGIN, UNITCHECK, CHECK, INIT and END" section. In addition to describing things well, it has a really great example which is basically a more complex version of the example I gave earlier.

why package {} is irrelevant ? which else language feature such as forward definitions ?

package { ... } is irrelevant to your example because the only thing that matters in your example is the order in which the variable was assigned versus where the variable was used.

As for language features, Perl is full of them. Perl is an extremely powerful language with a rich history. While there are some specific features that can be enabled or disabled, there are of course many, many more that are simply part of the language. You won't find a comprehensive list of them in one place, that I know of. To learn these features, just keep learning Perl! Keep writing code, keep giving yourself increasingly challenging projects, and look at as many good examples of Perl code you can find.1 Use the excellent Perl documentation every time you aren't sure of something (or browse a random Perl document on a topic that interests you), and you'll usually come away with an answer to your immediate question plus three or four other things you didn't know either. Read Perl books. Visit PerlMonks often, ask questions,2 be a part of the community, and you'll master the language quickly.

______________
1. Look at the source for core modules (find them on your system with perl -V and look for a .../perl/5.xx directory in the @INC section). Also browse MetaCPAN, find a popular module, and click the "Source" link. Just be aware that while most CPAN source is quite good, the quality of CPAN source code does vary from amazing to highly questionable. However, you will see different ways of doing things, and learning to identify good and bad code is an essential skill for any programmer. This will also help you to not re-invent the wheel, as Perl has a huge ecosystem of modules already. While learning, though, re-invent as many wheels as you like. :-)
2. Ask questions, and also answer some when you can! One of the best ways to learn anything is to force yourself to find a way to explain it to someone else.


In reply to Re^3: why package definition order affect the available of package variable by rjt
in thread why package definition order affect the available of package variable by fanasy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-18 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found