summaryrefslogtreecommitdiff
path: root/examples/next-in-loop/Error.pm-next.pl
blob: 4a0bab3626276ecb33a221d2791474d5484ff09e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/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;

foreach my $i (1 .. 100)
{
    try
    {
        if ($i % 10 == 0)
        {
            throw MyError;
        }
    }
    catch MyError with
    {
        my $E = shift;
        next;
    };
    print "$i\n";
}