in reply to Re^2: Strange modification of @_
in thread Strange modification of @_
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/.../.../; ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Strange modification of @_
by jrw (Monk) on Apr 24, 2009 at 20:23 UTC | |
by ikegami (Patriarch) on Apr 24, 2009 at 20:34 UTC | |
by jrw (Monk) on Apr 24, 2009 at 20:51 UTC | |
by ikegami (Patriarch) on Apr 24, 2009 at 21:58 UTC |