[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] my $a = blah();



$ cat j.pl

my $a = blah();

print "$a\n";


sub blah {

   return (7,8);

}


$ perl j.pl

8


Perl knows that blah() is being called in scalar context, so it evaluates (7,8) in scalar context, which is 8, because it's the rightmost value after the comma.

Now, if you'd said

my ($a) = blah();

then $a will be 7, and 8 gets ignored.

xoxo,
Andy


--
Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance