Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Passing Any Range of Values to a Sub

by kabel (Chaplain)
on Jul 02, 2003 at 05:19 UTC ( #270707=note: print w/ replies, xml ) Need Help??


in reply to Passing Any Range of Values to a Sub

to live TMTOWTDT out, here are some other ways;
one cannot recommend the first one, but the second is a clean way:

1. a nice eval-trick, i think abigail-II used it in a sig

eval join ('*', @list);
2. something more functional?
have a look at Language::Functional. the relevant bits are the functions foldl/foldr
$x = foldl { shift() + shift() } 0, [1..6]; # 21
this is the POD example.

HTH a bit at least :-)


Comment on Re: Passing Any Range of Values to a Sub
Select or Download Code
Re: Re: Passing Any Range of Values to a Sub
by Anonymous Monk on Jul 02, 2003 at 07:19 UTC
    print eval join (shift @ARGV eq 'add' ? '+' : '*', @ARGV);

    Fun, but maybe a bit unclear ...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (19)
As of 2014-07-31 14:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (249 votes), past polls