$ perl -e 'use strict; use warnings; sub foo { return ( 6, 7 ) } my
$got = foo(); print $got . "\n"'
7

$ perl -e 'use strict; use warnings; sub foo { my @ret = ( 6, 7 );
return @ret } my $got = foo(); print $got . "\n"'
2

Had me puzzled for a minute or two, til I realised the scalar context
changed the behaviour of the comma - proper explanation from perldoc
perlop:

    Binary "," is the comma operator.  In scalar context it evaluates
its left argument, throws that value away, then evaluates its right
argument and returns that value.

Alex
_______________________________________________
BristolBathPM mailing list
[email protected]
http://mailman.bristolbath.org/mailman/listinfo/bristolbathpm

Reply via email to