Return to Snippet

Revision: 1844
at November 13, 2006 02:26 by wolfie

Initial Code
print one();

sub one {
    my $result = two();

    if (ref $result eq 'ERROR') {
        die $result->{message};
    else {
        return $result;

sub two {
    if (rand(100) > 50) {
        return bless {message=>"There is a problem here."}, 'ERROR';
    return "Things are fine.";

Initial URL

Initial Description
Courtesy of Michael Mathews

Initial Title
How to return an error message or a value

Initial Tags

Initial Language