in reply to Strange modification of @_
$_[0] is aliased to $1. Clearing $1 will therefore clear $_[0], being the same variable. Don't pass globals to functions if that global is going to be modified in the function.
Fix:
s/(x)/fn "$1"/e;
This causes a new string to be created from the value of $1.
Update: Note that this isn't usually a problem with Pure Perl subs since @_ is usually only used at the top of the sub.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Strange modification of @_
by jrw (Monk) on Apr 23, 2009 at 19:57 UTC | |
by ikegami (Patriarch) on Apr 23, 2009 at 22:05 UTC | |
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 | |
|