Welcome to the Monastery | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
If you call split like this @rv = split $_[0], @_[ 1 .. 2 ] you get the return value undef. This is not true, it gives (99). Update 1: Presuming @_ = (qr{:}, 'a:b:c', 99) from the given example. Update 2: A capturing group in the regex does not change the result for this case. To understand this behaviour you need to consider function prototypes. The compiler recognises split being called with two arguments, where the second is a list that gets assigned to a single scalar. This results in the last element of the list being assigned to the scalar, just like in This behaviour is caused by the usage of an array slice. A "pure" array would be evaluated in scalar context giving its length. In the following example the sub show_args sees its arguments just like split. UPDATE 3: As suspected by bojinlund in Re^2: My problems to understand the Perl documentation and proven by LanX in Re^4: My problems to understand the Perl documentation, the sub show_args does not see its arguments exactly as split.
Greetings, In reply to Re: My problems to understand the Perl documentation [updated]
by jo37
|
|