I have a hash named %coins
.
I am to trying to modify the value of the hash if the key of the hash matches with some string.
I tried the following code, but couldn't succeed. It is creating new key instead of modifying the existing key's value.
Please help
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my %coins;
%coins = ( "abc" , 1,
"mno pqr" , 2,
"xyz", 3 );
print Dumper \%coins;
if(grep {/mno/} keys %coins)
{
print"matched \n";
$coins{$_} = s/$coins{$_}/new_val/g;
}
print Dumper \%coins;