my $str = "the boy walked the dog"; for ( $str ) { s/walked/fed/; s/boy/girl/; s/dog/Audrey II/; } #### my $str = "the boy walked the dog"; my %subs = ( "walked", "fed", "boy", "girl", "dog", "Audrey II" ); foreach ( keys %subs ) { $str =~ s/$_/$subs{$_}/; }