C:\> perl -E "my $var = 'rstuv'; $var =~ s/r/FOO/; say $var;" FOOstuv # replaced the "r" with "FOO"... and would have done the same if $var were a filename; # that is, it would have changed the filename in $var, not the content of the file. # Now that I've said it multiple times, does this make sense to you? C:\> perl -E "my $var = 'rstuv'; $var =~ tr/r/FOO/; say $var;" Fstuv # Grossly oversimplified, the tr///ran out of "r"s to change C:\> perl -E "my $var = 'rstuv'; my $newvar = $var =~ tr/r/FOO/; say $newvar;" 1 # count of the replacement actions