Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Looping backwards through two arrays at once?

by ickyb0d (Monk)
on Nov 04, 2005 at 12:08 UTC ( [id://505787]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Looping backwards through two arrays at once?

#since they're the same length... for(0..$#array1) { print $array1[$#array1 - $_]; print $array2[$#array2 - $_]; }
hope this helps.

UPDATE: Yeah, sorry, fixed 'em :).

Replies are listed 'Best First'.
Re^2: Looping backwards through two arrays at once?
by chester (Hermit) on Nov 04, 2005 at 12:11 UTC
    If you want to do it this way, shouldn't it be

    for(0..$#array1) { print $array1[$#array1 - $_]; print $array2[$#array2 - $_]; }

    EDIT: Oops, you fixed the array index. But you still have your $# reversed on two lines. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://505787]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.