foreach $string_to_fill_in (@strings) { $string_to_fill_in =~ s/\bNAME\b/$dbhash{name}/g; # repeat for as many parameters as you have }