#!/usr/bin/perl 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";