develooper Front page | perl.perl5.porters | Postings from January 2012

Re: defined(@arr), defined (%hash)

Thread Previous | Thread Next
Father Chrysostomos
January 3, 2012 10:01
Re: defined(@arr), defined (%hash)
Message ID:
Ricardo Signes wrote:
> C<defined> does not really impose scalar context as usually understood.  For
> example, defined(&foo) does not call foo in scalar context.  It is its own
> thing, which is, basically, the problem.

This is a syntactic distinction.  defined(&foo), defined(@foo) and defined(%foo) are special cases.  All others (should) work this way (bugs aside):

$ perl -le 'sub context { print qw[void scalar list][wantarray + defined wantarray] } defined context'

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About