You forgot to specify the return value for map. It's currently returning the result of s/// (which is 1) since it's the last operation performed.
my %testhash = map { my $val = (split /\//, $_)[-1]; (my $key = $val) =~ s/\.txt//; $key => $val # <-- added } @teststr;
In reply to Re: hash assignment using map with multiple statements
by ikegami
in thread hash assignment using map with multiple statements
by diomedea
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |