Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: effects of ampersand and non ampersand when referencing a sub name

by tobyink (Abbot)
on Dec 20, 2012 at 08:56 UTC ( #1009707=note: print w/replies, xml ) Need Help??


in reply to effects of ampersand and non ampersand when referencing a sub name

Using a coderef at all bypasses prototypes. (As does calling a sub as a method.)

If you need to check the number of arguments passed to a sub, do it in the sub! Prototypes are just to help the Perl parser parse argument lists more sanely.

sub execute { @_==3 or croak "execute() needs three arguments!!"; ...; }
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
  • Comment on Re: effects of ampersand and non ampersand when referencing a sub name
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009707]
help
Chatterbox?
[Dumu]: hello again jedikaiti! thanks everyone today for being in the monastery!
[Dumu]: and incidentally, in case you're dying to know, it's multiple web browser bookmark format files...
[ambrus]: Seeking afterwards might also work fine, I think.

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (12)
As of 2017-11-20 18:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (291 votes). Check out past polls.

    Notices?