sub f { 'xxx' =~ /(.*)/; print("$_[0]\n"); } 'aaa' =~ /(.*)/; f($1); # xxx 'aaa' =~ /(.*)/; f("$1"); # aaa
Perl passes arguments by reference, not by value. You are passing a global variable, and the global variable gets changed the by the called function before the argument is used. Passing a copy of the global avoids the problem.
In reply to Re: a MooseX Q that's driving me up the wall :)
by ikegami
in thread a MooseX Q that's driving me up the wall :)
by tj_thompson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |