Akhthar Parvez K wrote:
Hi,

Hello,

The following line stores the first return value by the function Function1 to 
the variable $name:

my ($name) = @_[0] = &Function1 ($arg);

The array slice @_[0] forces list context on the right side of the assignment but warns. $name in parentheses forces list context on the right side of the assignment.


but this one doesn't work:
my ($name) = $_[0] = &Function1 ($arg);

The scalar value $_[0] forces scalar context on the right side of the assignment.


Eventhough I've no issues to use the first one as long as it works well for me, 
but I'm getting the following warning:
Scalar value @_[0] better written as $_[0]

When you need list context for a scalar value then enclose it in parentheses (like you do for $name.)

my ( $name ) = ( $_[0] ) = Function1( $arg );




John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.               -- Damian Conway

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to