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

Re^2: Example 1

by Mabooka-Mabooka (Sexton)
on Apr 17, 2005 at 04:03 UTC ( #448570=note: print w/ replies, xml ) Need Help??


in reply to Re: Common Beginner Mistakes
in thread Common Beginner Mistakes

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.


Comment on Re^2: Example 1
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://448570]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2015-07-05 15:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls