it seems equally unnatural to write the body of fn() any differently (by making a copy of $_[0] before performing the substitution.
What are you talking about? Using one of my ($str) = @_; or my $str = shift; is standard practice, hardly unnatural.
If the issue is that you want both the original and the transformed string, you might also be interested in the following idiom:
sub fn { my ($old) = @_; (my $new = $old) =~ s/.../.../; ... }
In reply to Re^3: Strange modification of @_
by ikegami
in thread Strange modification of @_
by jrw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |