summaryrefslogtreecommitdiff
path: root/examples/next-in-loop/Error.pm-next-out-of-catch.pl
diff options
context:
space:
mode:
Diffstat (limited to 'examples/next-in-loop/Error.pm-next-out-of-catch.pl')
-rw-r--r--examples/next-in-loop/Error.pm-next-out-of-catch.pl43
1 files changed, 43 insertions, 0 deletions
diff --git a/examples/next-in-loop/Error.pm-next-out-of-catch.pl b/examples/next-in-loop/Error.pm-next-out-of-catch.pl
new file mode 100644
index 0000000..019fe38
--- /dev/null
+++ b/examples/next-in-loop/Error.pm-next-out-of-catch.pl
@@ -0,0 +1,43 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Error qw(:try);
+
+use IO::Handle;
+
+package MyError;
+
+use base 'Error';
+
+package SecondError;
+
+use base 'Error';
+
+package main;
+
+autoflush STDOUT 1;
+
+SHLOMIF_FOREACH:
+foreach my $i (1 .. 100)
+{
+ my $caught = 0;
+ try
+ {
+ if ($i % 10 == 0)
+ {
+ throw MyError;
+ }
+ }
+ catch MyError with
+ {
+ my $E = shift;
+ $caught = 1;
+ };
+ if ($caught)
+ {
+ next SHLOMIF_FOREACH;
+ }
+ print "$i\n";
+}