in reply to What does this mean? "return -$!"

Ah, I see, the minus forces it into a numeric context, and negative values is what we want here anyway. (Elegant!)

And further, that $! is a dualvar, and that there is such a thing as "dualvars", explains to me what I, until today, never fully understood about error handling, which often deals with these two-sided text vs. return-value conditions... Heureka!

Replies are listed 'Best First'.
Re^2: What does this mean? "return -$!"
by tobyink (Canon) on Nov 02, 2012 at 21:12 UTC

    Recent versions of Perl (since 5.8) have shipped with Scalar::Util that allows you to define your own dualvars. (The module is also available on CPAN for earlier versions of Perl.)

    use 5.010; use Scalar::Util qw( dualvar ); my $x = dualvar(7, "Seven"); say "$x"; say $x+0;
    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'