in reply to hash assignment using map with multiple statements
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: hash assignment using map with multiple statements
by diomedea (Sexton) on Sep 19, 2008 at 08:40 UTC |