And so others can get the benefit of your wisdom w/o
the OOPerl book
(but buy it nonetheless, its a great book), pg 34
gives the example: sub listdir
{
# do file listing and the:
return @missing_files if wantarray();
return $listed_count if defined(wantarray());
carp "subroutine &listdir was called in a void context";
} # sub listdir
The really cool thing here: wantarray returns true if:
@missing = listdir(@files);
(called in a list context); returns "" (i.e. false but defined) if:
$list_count = listdir(@files);
(called in a scalar context) and returns undef if:
listdir(@files);
(called in a void context - get the carp).
a |