return 0 or return bare

Aaron Crane perl at
Thu Dec 13 12:45:41 GMT 2012

pierre masci <piemas25 at> wrote:
> And now i'm thinking that a scalar function should maybe throw an exception
> when called in list context; for the reason mentioned above.

I suspect that would be extremely annoying in practice.

sub foo {
    confess "Scalar-only routine called in list context" if wantarray;

# Now this throws an exception:
my %hash = (foo => foo());

Aaron Crane **

More information about the mailing list