in reply to Foreach two arrays?
#!/usr/bin/perl -wT use strict; my @a = qw(1 2 3 4 5 6); my @b = qw(a b c d e f g h i); my $max = $#a > $#b ? $#a : $#b; # find the max index of the biggest +array for my $i (0..$max) { # loop through using the same index +variable print "$a[$i]\n" if defined $a[$i]; print "$b[$i]\n" if defined $b[$i]; } =OUTPUT 1 a 2 b 3 c 4 d 5 e 6 f g h i
-Blake
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Foreach two arrays?
by broquaint (Abbot) on Sep 06, 2001 at 17:15 UTC | |
|
Re: Re: Foreach two arrays?
by Dylan (Monk) on Sep 06, 2001 at 10:12 UTC |