in reply to Missing Hash Keys When Hash Created in Sub
What version of perl are you using? 5.8.8 (msys) / 5.8.9 (AS 826) both exhibit this behavior. 5.18.2 Strawberry does not.
#!perl use strict; use warnings; my %hash = ( "A" => 1, "B" => 1, "C" => 1, "D" => 1, "E" => 1, "B" => 1, "F" => 1, "G" => 1, "H" => 1, "I" => 1, "J" => 1, ); for my $key (sort(keys(%hash))) { print "$key\n"; } print "_"x10,"\n"; my %hash2 = makesubhash(); for my $key (sort(keys(%hash2))) { print "$key\n"; } sub makesubhash { my %subhash = ( "A" => 1, "B" => 1, "C" => 1, "D" => 1, "E" => 1, "B" => 1, "F" => 1, "G" => 1, "H" => 1, "I" => 1, "J" => 1, ); }
Perl 5.8.8/5.8.9
A B C D E F G H I J __________ B C D E F G H I
Perl 5.18.2
A B C D E F G H I J __________ A B C D E F G H I J
--MidLifeXis
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Missing Hash Keys When Hash Created in Sub
by Stringer (Acolyte) on Feb 23, 2015 at 21:29 UTC |