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;
In reply to Re^5: Convert a string into a hash
by ikegami
in thread Convert a string into a hash
by vitoco
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |