in reply to subroutine list return
Second, the subroutine's last expression (the return value) is evaluated in the context of the caller. The expression:
doesn't assign 4 to $ret_val. It uses the comma operator to calcuate the elements of the list one by one, and then discards all but the last, thus returning 1 there.my $ret_val = (@array, 1);
I have a column on context that you might find useful.
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
|---|