Jeff mentioned in one post something about Tie::IxHash, which would be better than this for using a hash but keeping the order preserved. Not sure if that'd work for you, as I've never tried it. ;)
==================== Brian Arnold [EMAIL PROTECTED] > -----Original Message----- > From: Etienne Marcotte [mailto:[EMAIL PROTECTED]] > Sent: Friday, October 26, 2001 12:00 PM > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: Re: create hash and print all elements? > > > Thanks > > I need to keep the order for the SQL statement.. > > Do you think that any method is better? (one array or two) > > Etienne > > Jeff 'japhy' Pinyan wrote: > > > 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] > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]