in reply to Re^4: Convert a string into a hash
in thread Convert a string into a hash
It's not using strict :)
Package var $i is used when you intended lexical $i to be used. Why bother declaring lexical $i if you're not going to use it and you're ok with using the (unlocalised!!!) package var? Your code is equivalent to
my %code = map { $_ => $i++ } split /,/, $tokens; my $i = 0
so you should use the following is you think it's fine
my %code = map { $_ => $i++ } split /,/, $tokens;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Convert a string into a hash
by vitoco (Hermit) on Aug 15, 2009 at 16:56 UTC |