Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Advice on loops

by merlyn (Sage)
on May 03, 2007 at 15:27 UTC ( [id://613396]=note: print w/replies, xml ) Need Help??


in reply to Advice on loops

Just use a recursive routine to drill down. Witness:
my @array=(['john','tom','peter'],['rose','teak'],['car','truck','jeep +'],['trees','plants'],['good','bad','ugly']); my @arrayindex=(3,1); my @wanted = @array[@arrayindex]; # get slice show(@wanted); sub show { if (ref @_[0]) { # still recursing for (@{+shift}) { show(@_, $_); } } else { # end case print "@_\n"; # do what you want with the results here } }
This prints:
trees rose trees teak plants rose plants teak

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2024-03-28 14:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found