1Fatal(3pm)             Perl Programmers Reference Guide             Fatal(3pm)
2
3
4

NAME

6       Fatal - replace functions with equivalents which succeed or die
7

SYNOPSIS

9           use Fatal qw(open close);
10
11           sub juggle { . . . }
12           import Fatal 'juggle';
13

DESCRIPTION

15       "Fatal" provides a way to conveniently replace functions which normally
16       return a false value when they fail with equivalents which raise excep‐
17       tions if they are not successful.  This lets you use these functions
18       without having to test their return values explicitly on each call.
19       Exceptions can be caught using "eval{}".  See perlfunc and perlvar for
20       details.
21
22       The do-or-die equivalents are set up simply by calling Fatal's "import"
23       routine, passing it the names of the functions to be replaced.  You may
24       wrap both user-defined functions and overridable CORE operators (except
25       "exec", "system" which cannot be expressed via prototypes) in this way.
26
27       If the symbol ":void" appears in the import list, then functions named
28       later in that import list raise an exception only when these are called
29       in void context--that is, when their return values are ignored.  For
30       example
31
32               use Fatal qw/:void open close/;
33
34               # properly checked, so no exception raised on error
35               if(open(FH, "< /bogotic") {
36                       warn "bogo file, dude: $!";
37               }
38
39               # not checked, so error raises an exception
40               close FH;
41

AUTHOR

43       Lionel.Cons@cern.ch
44
45       prototype updates by Ilya Zakharevich ilya@math.ohio-state.edu
46
47
48
49perl v5.8.8                       2001-09-21                        Fatal(3pm)
Impressum