return 0 or return bare

Aaron Crane perl at aaroncrane.co.uk
Thu Dec 13 12:45:41 GMT 2012


pierre masci <piemas25 at gmail.com> 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 ** http://aaroncrane.co.uk/


More information about the london.pm mailing list