Chas. Owens wrote:
If you want to print out only pairs you can use the code below.  If
you want to print out all of the items in the the longer array, then
change the <= to >=

In that case you'd better prevent Perl from spitting out uninitialized warnings...

#!/usr/bin/perl

use strict;
use warnings;

my @a = qw<a b c d e>;
my @b = (1, 2, 3);

my $len = @a <= @b ? @a : @b;

for my $i (0 .. $len - 1) {
        print "$a[$i]\t$b[$i]\n";
}

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to