... @seq = qw(dirt sand land air wind breath); foreach (@seq) { print $param{$_} . "\n"; } is one way ...
-----Original Message----- From: Shannon Murdoch [mailto:[EMAIL PROTECTED]] Sent: October 24, 2001 19:01 To: [EMAIL PROTECTED] Subject: Re: Printing Hash Keys Thanks RaFaL, print join "\t", sort keys %params; works excellently. What if I don't want to sort them (display the keys in the same order they were entered)? Let's say the hash was: %params = qw( dirt 4 sand 5 land 2 air 5 wind 9 breath 1 ); A sorted hash would come out as: air breath dirt land sand wind 5 1 4 2 5 9 how can I make it come out the same order I entered them? ie. dirt sand land air wind breath 4 5 2 5 9 1 Cheers, -Shannon > From: [EMAIL PROTECTED] (Rafal Pocztarski) > Newsgroups: perl.beginners.cgi > Date: Wed, 24 Oct 2001 16:04:19 +0200 > To: [EMAIL PROTECTED] > Subject: Re: Printing Hash Keys > > Shannon Murdoch wrote: >> >> What everyone has said so far is ways to list all the VALUES contained in a >> hash array, what I need to do is list all the KEYS contained in the hash >> array-with a tab (\t) between each. > > print join "\t", sort keys %hashname; > > - RaFaL Pocztarski, [EMAIL PROTECTED] -- 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]