diff options
author | Lukas Mai <l.mai@web.de> | 2016-09-18 09:50:16 +0200 |
---|---|---|
committer | Lukas Mai <l.mai@web.de> | 2016-09-18 09:52:00 +0200 |
commit | f26064794a6949d593fcd01d326c28a09f3088f0 (patch) | |
tree | 831b03a497bafc7402b40b673a8f7ba985d2f51e | |
parent | 178122f6e0bac976a9e16e3553b9469414d70f3c (diff) | |
download | perl-f26064794a6949d593fcd01d326c28a09f3088f0.tar.gz |
perlsub: scalar split no longer clobbers @_ (RT #129297)
-rw-r--r-- | pod/perlsub.pod | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/pod/perlsub.pod b/pod/perlsub.pod index f15f9cea3a..434bb8c7b9 100644 --- a/pod/perlsub.pod +++ b/pod/perlsub.pod @@ -1582,14 +1582,14 @@ and someone has been calling it with an array or expression returning a list: func(@foo); - func( split /:/ ); + func( $text =~ /\w+/g ); Then you've just supplied an automatic C<scalar> in front of their argument, which can be more than a bit surprising. The old C<@foo> which used to hold one thing doesn't get passed in. Instead, C<func()> now gets passed in a C<1>; that is, the number of elements -in C<@foo>. And the C<split> gets called in scalar context so it -starts scribbling on your C<@_> parameter list. Ouch! +in C<@foo>. And the C<m//g> gets called in scalar context so instead of a +list of words it returns a boolean result and advances C<pos($text)>. Ouch! If a sub has both a PROTO and a BLOCK, the prototype is not applied until after the BLOCK is completely defined. This means that a recursive |