in reply to Re^2: Replace a hash key if it matches a regex
in thread Replace a hash key if it matches a regex

See perlsyn - Perl syntax for details:
The behaviour of a my, state, or our modified with a statement modifier conditional or loop construct (for example, my $x if ...) is undefined. The value of the my variable may be undef, any previously assigned value, or possibly anything else. Don't rely on it. Future versions of perl might do something different from the version of perl you try it out on. Here be dragons.

You can use the following:

if (my ($match) = $_ =~ /...(...).../) { $db_results->{$match} = delete $db_results->{$_} }

For $_, you can omit the $_ =~ part.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^4: Replace a hash key if it matches a regex
by walkingthecow (Friar) on Sep 14, 2013 at 03:56 UTC
    Awesome. Thanks to both of you for taking the time to correct me on this and explain it so well.