Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Technique for building arguments from function name?

by Anonymous Monk
on Dec 04, 2017 at 19:55 UTC ( [id://1204887]=note: print w/replies, xml ) Need Help??


in reply to Technique for building arguments from function name?

Corion's suggestion provides a function_* for every *. This one only creates the ones you list. Whatever works for you.
for my $x (qw( cat dog fish )) { no strict 'refs'; *{"function_$x"} = sub { print $x }; } function_cat(); # print "cat" function_banana(); # error

Replies are listed 'Best First'.
Re^2: Technique for building arguments from function name?
by nysus (Parson) on Dec 04, 2017 at 20:01 UTC

    Ah, nifty and easy. That could be just what I need. Thanks!

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

Log In?
Username:
Password:

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

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

    No recent polls found