Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Calling Functions

by JavaFan (Canon)
on Mar 28, 2012 at 09:43 UTC ( [id://962132]=note: print w/replies, xml ) Need Help??


in reply to Calling Functions

For me, the biggest difference is that if you neither use & nor use parenthesis, a mistyped subroutine name will be a compile time error (with strict) or warning (with warnings enabled), instead of a run time error.
$ perl -Mstrict -wce 'sub f {1;} &g' -e syntax OK $ perl -Mstrict -wce 'sub f {1;} g()' -e syntax OK $ perl -Mstrict -wce 'sub f {1;} g' Bareword "g" not allowed while "strict subs" in use at -e line 1. -e had compilation errors. $ perl -wce 'sub f {1;} g' Unquoted string "g" may clash with future reserved word at -e line 1. Useless use of a constant (g) in void context at -e line 1. -e syntax OK $ perl -Mstrict -wce 'sub f {1;} f' -e syntax OK $

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-19 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found