in reply to Re: hash substrings
in thread hash substrings
foreach my $k (@k) { $s =~ m/(.)$k(.)/ ; if (($1 ne "\0") || ($2 ne "\0")) { delete $h{$k} ; } ; }
You shouldn't use the variables $1 and $2 unless the match was successful because they retain their previous value if the match failed and so after the first successful match every key will be deleted.
for my $k ( @k ) { if ( $s =~ /\0$k\0/ ) { delete $h{ $k }; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: hash substrings
by gone2015 (Deacon) on Jan 27, 2009 at 10:54 UTC |