You're asking what context the function is being called in. There are (basically) three contexts in Perl - void, scalar and list. You can use the wantarray function to determine how your function has been called.
sub how { my $how = wantarray; if (defined $how) { if ($how) { print "list\n"; } else { print "scalar\n"; } } else { print "void\n"; } } how; my $s = how; my @a = how;
For your question I think you just need to check if the return value from wantarray is defined.
--"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re: subroutines & functions
by davorg
in thread subroutines & functions
by toonski
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |