autodie
view release on metacpan or search on metacpan
lib/autodie.pm view on Meta::CPAN
and subroutines altered with C<autodie> will only change their behaviour
until the end of the enclosing block, file, or C<eval>.
If C<system> is specified as an argument to C<autodie>, then it
uses L<IPC::System::Simple> to do the heavy lifting. See the
description of that module for more information.
=head1 EXCEPTIONS
Exceptions produced by the C<autodie> pragma are members of the
L<autodie::exception> class. The preferred way to work with
these exceptions under Perl 5.10 is as follows:
eval {
use autodie;
open(my $fh, '<', $some_file);
my @records = <$fh>;
# Do things with @records...
close($fh);
};
if ($@ and $@->isa('autodie::exception')) {
if ($@->matches('open')) { print "Error from open\n"; }
if ($@->matches(':io' )) { print "Non-open, IO error."; }
} elsif ($@) {
# A non-autodie exception.
}
See L<autodie::exception> for further information on interrogating
exceptions.
=head1 CATEGORIES
Autodie uses a simple set of categories to group together similar
built-ins. Requesting a category type (starting with a colon) will
enable autodie for all built-ins beneath that category. For example,
requesting C<:file> will enable autodie for C<close>, C<fcntl>,
C<open> and C<sysopen>.
The categories are currently:
:all
:default
:io
read
seek
sysread
sysseek
syswrite
:dbm
dbmclose
dbmopen
:file
binmode
close
chmod
chown
fcntl
flock
ioctl
open
sysopen
truncate
:filesys
chdir
closedir
opendir
link
mkdir
readlink
rename
rmdir
symlink
unlink
:ipc
kill
pipe
:msg
msgctl
msgget
msgrcv
msgsnd
:semaphore
semctl
semget
semop
:shm
shmctl
shmget
shmread
:socket
accept
bind
connect
getsockopt
listen
recv
send
setsockopt
shutdown
socketpair
:threads
fork
:system
system
exec
Note that while the above category system is presently a strict
hierarchy, this should not be assumed.
A plain C<use autodie> implies C<use autodie qw(:default)>. Note that
C<system> and C<exec> are not enabled by default. C<system> requires
the optional L<IPC::System::Simple> module to be installed, and enabling
C<system> or C<exec> will invalidate their exotic forms. See L</BUGS>
below for more details.
( run in 2.410 seconds using v1.01-cache-2.11-cpan-524268b4103 )