~ubuntu-branches/ubuntu/precise/liberror-perl/precise

« back to all changes in this revision

Viewing changes to examples/next-in-loop/Error.pm-next.pl

  • Committer: Bazaar Package Importer
  • Author(s): Clint Burfoot
  • Date: 2007-12-02 16:20:39 UTC
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20071202162039-d19hm6p5v0r8bx5v
Tags: upstream-0.17
ImportĀ upstreamĀ versionĀ 0.17

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
use strict;
 
4
use warnings;
 
5
 
 
6
use Error qw(:try);
 
7
 
 
8
use IO::Handle;
 
9
 
 
10
package MyError;
 
11
 
 
12
use base 'Error';
 
13
 
 
14
package SecondError;
 
15
 
 
16
use base 'Error';
 
17
 
 
18
package main;
 
19
 
 
20
autoflush STDOUT 1;
 
21
 
 
22
foreach my $i (1 .. 100)
 
23
{
 
24
    try
 
25
    {
 
26
        if ($i % 10 == 0)
 
27
        {
 
28
            throw MyError;
 
29
        }
 
30
    }
 
31
    catch MyError with
 
32
    {
 
33
        my $E = shift;
 
34
        next;
 
35
    };
 
36
    print "$i\n";
 
37
}