advanced code snippet search
wolfie on 11/13/06
perl Error-handling
11/13/06 02:26am
Courtesy of Michael Mathews
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.";}
Report this snippet Tweet
Comment:
You need to login to post a comment.