Here's another "What's a quick and real neat way of...." type question
Piers Harding
piers at ompa.net
Thu Nov 14 04:46:19 CST 2002
how about this:
while (my ($a, $b) = (shift @a, shift @b)){
do the funky thing with $a and $b ....
}
Cheers.
On Thu, Nov 14, 2002 at 11:06:14PM +1300, Enkidu wrote:
> Say you have two arrays @a and @b.
>
> You can loop through one array by using foreach:
>
> for my $file (@a) {
> <do something with $file> ;
> }
>
> Is there a neat way of looping through *both arrays* at the same time?
> Something like:
>
> for my ($file, $desc) (@a, @b) {
> <do something with $file, $desc> ;
> }
>
> Cheers,
>
> Cliff
> --
>
> The Nats held a Party and no one came.
More information about the Wellington-pm
mailing list