my @subs = ( ['\?a\?' => 'aRep'], ['\?b\?' => 'bRep'], ['\?c\?' => 'cRep'], ); for my $match (@subs) { $string =~ s/$match->[0]/$match->[1]/g; }