jrw has asked for the wisdom of the Perl Monks concerning the following question:
Can someone explain why @_ is modified? I thought my ($str) = @_ made a copy of the elements of @_./usr/bin/perl -we ' use strict; sub fn { my ($str) = @_; print "<@_>\n"; $str =~ s/x//; print "<@_>\n"; } $_ = "x"; s/(x)/fn $1/e; ' <x> Use of uninitialized value $_[0] in join or string at -e line 5. <>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Strange modification of @_
by ikegami (Patriarch) on Apr 23, 2009 at 17:52 UTC | |
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 | |
| |
|
Re: Strange modification of @_
by ELISHEVA (Prior) on Apr 23, 2009 at 18:26 UTC | |
|
Re: Strange modification of @_
by jwkrahn (Abbot) on Apr 23, 2009 at 18:59 UTC |