use strict;
my $test = 'The brown fox int(10) over float(200) fence.';
my %dict = (
'brown' => 'yellow',
/int(\d+)/ => 'int',
/float(\d+)/ => 'float',
);
use Data::Dumper;
warn Dumper \%dict;
__END__
$VAR1 = {
'int' => 'float',
'brown' => 'yellow'
};
####
my %dict = (
'brown' => 'yellow',
qr/int(\d+)/ => 'int',
qr/float(\d+)/ => 'float',
);
##
##
use strict;
my $test = 'The brown fox int(10) over float(200) fence.';
my %dict = (
'brown' => 'yellow',
'int\(\d+\)' => 'int',
'float\(\d+\)' => 'float',
);
for my $i ( keys %dict ) {
$test =~ s/$i/$dict{$i}/gi;
}
print "$test\n";