On Oct 26, Etienne Marcotte said:
>my @color_array = (
> ["sky", "blue"],
> ["grass", "green"],
> ["apple", "red"]
> );
>
>I'd like to print: sky, grass, apple = blue, green, red
That'd be better suited by a hash, but that means the order won't be the
one you'd like it to be.
my %colors = (
sky => 'blue',
grass => 'green',
apple => 'red',
);
print join(", ", keys %colors), " = ", join(", ", values %colors);
But using the array method you can do what you requested:
print
join(", ", map $_->[0], @colors),
" = ",
join(", ", map $_->[1], @colors);
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]