$_[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.
In reply to Re: Strange modification of @_
by ikegami
in thread Strange modification of @_
by jrw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |