sub foo { if( $error ){ return bless [0, "error was ..."] => 'YouveGotError' } return [42,43] } my $ret = foo(); die "@$ret" if ref($ret) eq 'YouveGotError';