Hi
Could anyone explain why the output of the hash isn't: 1 a
2 b
3 c
How can i make that the order remains the same in the hash??
Thx
@count = (1,'a',2,'b',3,'c'); print @count; #output: 1a2b3c print "\n";
%c = @count; foreach $abc (keys %c){ print $abc.' '.$c{$abc}."\n" #output: 1 a ; # 3 c } # 2 b
Due to the way that Perl stores hashes, there is no guarantee that data will come out in the same order that it went in. Although, in the above case, you could do:
my %c = @count; foreach $abc (sort(keys %c)) { print "$abc $c{$abc}\n"; }
-- Andrew Gaffney Network Administrator Skyline Aeronautics, LLC. 636-357-1548
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>