in reply to Re^3: Using substr on Hash Keys
in thread Using substr on Hash Keys
$hash{ do{ $_ =~ s/(..)$//; $_ } } = delete $hash{ $_ } for keys % +hash;
What appears to happen is that the lvalue is evaluated first, so I end up deleting the modified key into the new key position (leaving all the old keys in place and defining new keys to undef); but I couldn't have guessed until I tried it, so I'd tend to lean toward a for() loop like my first post.
And I think that was jwkrahn's point too:
$hash{ substr $_, 1, 20, "" } = delete $hash{ $_ } for keys %hash;
-Paul
|
|---|