This is probably a silly question but I'm asking it anyway. I'm pretty sure it's not possible in Perl but I'm wondering if something like this technique has a name. So let's say I have the following functions:
sub function_cat { print "cat"; } sub function_dog { print "dog"; }
Each time I want to print a new word, I write a new function.
But instead, is it possible to do something like this:
sub function_x { print $x; } function_tiger(); # yields "tiger"
Sure, I could create a generic function and do function('fish') but function_fish is so much easier. :)
$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks
In reply to Technique for building arguments from function name? by nysus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |