1Fatal(3)              User Contributed Perl Documentation             Fatal(3)
2
3
4

NAME

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

SYNOPSIS

9           use Fatal qw(open close);
10
11           open(my $fh, "<", $filename);  # No need to check errors!
12
13           use File::Copy qw(move);
14           use Fatal qw(move);
15
16           move($file1, $file2); # No need to check errors!
17
18           sub juggle { . . . }
19           Fatal->import('juggle');
20

BEST PRACTICE

22       Fatal has been obsoleted by the new autodie pragma. Please use autodie
23       in preference to "Fatal".  autodie supports lexical scoping, throws
24       real exception objects, and provides much nicer error messages.
25
26       The use of ":void" with Fatal is discouraged.
27

DESCRIPTION

29       "Fatal" provides a way to conveniently replace functions which normally
30       return a false value when they fail with equivalents which raise
31       exceptions if they are not successful.  This lets you use these
32       functions without having to test their return values explicitly on each
33       call.  Exceptions can be caught using "eval{}".  See perlfunc and
34       perlvar for details.
35
36       The do-or-die equivalents are set up simply by calling Fatal's "import"
37       routine, passing it the names of the functions to be replaced.  You may
38       wrap both user-defined functions and overridable CORE operators (except
39       "exec", "system", "print", or any other built-in that cannot be
40       expressed via prototypes) in this way.
41
42       If the symbol ":void" appears in the import list, then functions named
43       later in that import list raise an exception only when these are called
44       in void context--that is, when their return values are ignored.  For
45       example
46
47           use Fatal qw/:void open close/;
48
49           # properly checked, so no exception raised on error
50           if (not open(my $fh, '<', '/bogotic') {
51               warn "Can't open /bogotic: $!";
52           }
53
54           # not checked, so error raises an exception
55           close FH;
56
57       The use of ":void" is discouraged, as it can result in exceptions not
58       being thrown if you accidentally call a method without void context.
59       Use autodie instead if you need to be able to disable autodying/Fatal
60       behaviour for a small block of code.
61

DIAGNOSTICS

63       Bad subroutine name for Fatal: %s
64           You've called "Fatal" with an argument that doesn't look like a
65           subroutine name, nor a switch that this version of Fatal
66           understands.
67
68       %s is not a Perl subroutine
69           You've asked "Fatal" to try and replace a subroutine which does not
70           exist, or has not yet been defined.
71
72       %s is neither a builtin, nor a Perl subroutine
73           You've asked "Fatal" to replace a subroutine, but it's not a Perl
74           built-in, and "Fatal" couldn't find it as a regular subroutine.  It
75           either doesn't exist or has not yet been defined.
76
77       Cannot make the non-overridable %s fatal
78           You've tried to use "Fatal" on a Perl built-in that can't be
79           overridden, such as "print" or "system", which means that "Fatal"
80           can't help you, although some other modules might.  See the "SEE
81           ALSO" section of this documentation.
82
83       Internal error: %s
84           You've found a bug in "Fatal".  Please report it using the
85           "perlbug" command.
86

BUGS

88       "Fatal" clobbers the context in which a function is called and always
89       makes it a scalar context, except when the ":void" tag is used.  This
90       problem does not exist in autodie.
91
92       "Used only once" warnings can be generated when "autodie" or "Fatal" is
93       used with package filehandles (eg, "FILE").  It's strongly recommended
94       you use scalar filehandles instead.
95

AUTHOR

97       Original module by Lionel Cons (CERN).
98
99       Prototype updates by Ilya Zakharevich <ilya@math.ohio-state.edu>.
100
101       autodie support, bugfixes, extended diagnostics, "system" support, and
102       major overhauling by Paul Fenwick <pjf@perltraining.com.au>
103

LICENSE

105       This module is free software, you may distribute it under the same
106       terms as Perl itself.
107

SEE ALSO

109       autodie for a nicer way to use lexical Fatal.
110
111       IPC::System::Simple for a similar idea for calls to "system()" and
112       backticks.
113
114
115
116perl v5.26.3                      2015-07-09                          Fatal(3)
Impressum