in reply to help needed in wantarray
The "context" means the context that the function is called in -- whether the values of the function will be used in list or scalar context.
use strict; use warnings; sub what_do_you_want { print wantarray ? "list\n" : "scalar\n"; } my @list = what_do_you_want(); # prints "list" my $scalar = what_do_you_want() # prints "scalar"
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
|---|