Excellent! I think that finally explains it.
If you focus on what an array evaluates to you'll get more to the point.
Whatever expression return will be evaluated in the context of the sub's call (as described by wantarray), and passed out that way.
Would you also say that return &foo obviously returns a subroutine?
No, but I don't consider "&foo" to be a passable data structure. The only time it isn't a call to a sub is (1) if it has "\" in front of it (making a reference), (2) if it has defined or exists in front of it, and (3) some other surprise I haven't discovered yet.
sub foo { die 'call to foo' }
print 'foo is ', defined &foo ? 'defined' : 'not defined', "\n";
print 'bar is ', defined &bar ? 'defined' : 'not defined', "\n";
__END__
foo is defined
bar is not defined
Many thanks for your reply. I do believe you have penetrated my concrete cranium. |