in reply to Re: Re: Re: string context and list operators (was Re: Array in scalar context.)
in thread Array in scalar context.
join, like all perl functions, takes lists as arguments (and conveniently provides them in the magical @_ array).Another good example is substr. It can be used in lvalue context ( special context for subroutines, means you can assign to their result)
As you can see substr has special behaviour in lvalue context. RValue means the result is treated as an ordinary value.use strict; use warnings; my $a = 'abcdefg'; print $a,$/; print substr($a,0,3),$/; # rvalue (list) print $a,$/; print substr($a,0,3)='bob',$/; # lvalue print $a,$/; print scalar( substr($a,0,3,'ABC')),$/; # rvalue (scalar) print $a,$/; __END__ abcdefg abc abcdefg bob bobdefg bob ABCdefg
|
|---|