sub()
This one was the reason I came here, details are in the
Seekers of Perl Wisdom thread.
(THANKS again BUU!!!).
In short: if you write
sub foo() {
...
},
you're in trouble.
Why people do this?
Mainly (I think) because it's counter-intuitive to do otherwise. I personally automatically without thinking add "()" to a function declaration. Besides, I call it as "foo()".
Another reasons: Perl allows you to do that. What I encountered is,
depending on where one calls sush sub, -- before or after it's defInition(!!!), there'll be a syntax error or no errors. (In fact, after fixing my small problem today, I looked closer at my colleague's module and found several dozen subs declared like this. No complaints from Perl).
Solution
Read all books, spend several years practicing. I leave to the experts the explanation of what "sub name()" really means (it's an array of subs or smth. like that I guess).
-- Find out.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.