#!/usr/bin/perl use warnings FATAL => 'all'; use strict; my @cases = 1..19; for my $case ( @cases ) { if (eval { interesting($case) }) { eval { process($case); }; print "$case had processing errors: $@" if $@; } elsif ($@) { print "$case had interesting errors: $@"; } else { print "$case not interesting.".$/; next; } } sub interesting { my $case = shift; die "random failure on interesting" if rand() > 0.7; return rand()>0.5?1:0; } sub process { my $case = shift; print "doing something with $case".$/; die "random failure on process" if rand() > 0.7; } #### 1 had interesting errors: random failure on interesting at /tmp/test.pl line 21. 2 had interesting errors: random failure on interesting at /tmp/test.pl line 21. doing something with 3 4 had interesting errors: random failure on interesting at /tmp/test.pl line 21. 5 not interesting. 6 not interesting. doing something with 7 8 not interesting. 9 not interesting. doing something with 10 10 had processing errors: random failure on process at /tmp/test.pl line 28. 11 not interesting. 12 not interesting. 13 not interesting. doing something with 14 14 had processing errors: random failure on process at /tmp/test.pl line 28. 15 not interesting. 16 had interesting errors: random failure on interesting at /tmp/test.pl line 21. 17 not interesting. doing something with 18 18 had processing errors: random failure on process at /tmp/test.pl line 28. doing something with 19