/snap/gh/640/usr/share/perl/5.38.2
NameSizeModeActions
App/-0755rm
Archive/-0755rm
Attribute/-0755rm
autodie/-0755rm
B/-0755rm
Carp/-0755rm
Class/-0755rm
Compress/-0755rm
Config/-0755rm
CPAN/-0755rm
DBM_Filter/-0755rm
Devel/-0755rm
Digest/-0755rm
Encode/-0755rm
encoding/-0755rm
Exporter/-0755rm
ExtUtils/-0755rm
File/-0755rm
Filter/-0755rm
Getopt/-0755rm
HTTP/-0755rm
I18N/-0755rm
IO/-0755rm
IPC/-0755rm
JSON/-0755rm
Locale/-0755rm
Math/-0755rm
Memoize/-0755rm
Module/-0755rm
Net/-0755rm
overload/-0755rm
Params/-0755rm
Parse/-0755rm
Perl/-0755rm
PerlIO/-0755rm
Pod/-0755rm
pod/-0755rm
Search/-0755rm
TAP/-0755rm
Term/-0755rm
Test/-0755rm
Test2/-0755rm
Text/-0755rm
Thread/-0755rm
Tie/-0755rm
Time/-0755rm
Unicode/-0755rm
unicore/-0755rm
User/-0755rm
version/-0755rm
warnings/-0755rm
AnyDBM_File.pm26180644editdlrm
autodie.pm124360644editdlrm
AutoLoader.pm157970644editdlrm
AutoSplit.pm196370644editdlrm
autouse.pm42380644editdlrm
base.pm109610644editdlrm
Benchmark.pm310230644editdlrm
bigfloat.pm219680644editdlrm
bigint.pm232470644editdlrm
bignum.pm282170644editdlrm
bigrat.pm211340644editdlrm
blib.pm20620644editdlrm
builtin.pm103920644editdlrm
bytes.pm37820644editdlrm
bytes_heavy.pl7580644editdlrm
Carp.pm359940644editdlrm
charnames.pm210490644editdlrm
constant.pm147240644editdlrm
CORE.pod31880644editdlrm
CPAN.pm1479710644editdlrm
DB.pm189220644editdlrm
DBM_Filter.pm143850644editdlrm
deprecate.pm50360644editdlrm
diagnostics.pm193340644editdlrm
Digest.pm112250644editdlrm
DirHandle.pm20850644editdlrm
Dumpvalue.pm176680644editdlrm
dumpvar.pl155550644editdlrm
English.pm47610644editdlrm
Env.pm55690644editdlrm
experimental.pm89300644editdlrm
Exporter.pm192120644editdlrm
Fatal.pm592360644editdlrm
feature.pm545970644editdlrm
fields.pm94750644editdlrm
FileCache.pm55490644editdlrm
FileHandle.pm68050644editdlrm
filetest.pm40030644editdlrm
FindBin.pm46160644editdlrm
if.pm36310644editdlrm
integer.pm32540644editdlrm
Internals.pod25750644editdlrm
less.pm32040644editdlrm
locale.pm48850644editdlrm
Memoize.pm325860644editdlrm
meta_notation.pm20690644editdlrm
NEXT.pm189820644editdlrm
ok.pm9670644editdlrm
open.pm84980644editdlrm
overload.pm547230644editdlrm
overloading.pm18080644editdlrm
parent.pm27020644editdlrm
perl5db.pl3175700644editdlrm
perlfaq.pm770644editdlrm
PerlIO.pm142590644editdlrm
Safe.pm253520644editdlrm
SelectSaver.pm10760644editdlrm
SelfLoader.pm176860644editdlrm
sigtrap.pm87330644editdlrm
sort.pm29920644editdlrm
stable.pm46570644editdlrm
strict.pm47830644editdlrm
subs.pm9450644editdlrm
Symbol.pm49050644editdlrm
Test.pm300420644editdlrm
Test2.pm63930644editdlrm
Thread.pm82890644editdlrm
UNIVERSAL.pm68340644editdlrm
utf8.pm108880644editdlrm
vars.pm24580644editdlrm
version.pm19760644editdlrm
version.pod98320644editdlrm
vmsish.pm43130644editdlrm
warnings.pm570690644editdlrm
XSLoader.pm113990644editdlrm
_charnames.pm356790644editdlrm
Edit: /snap/gh/640/usr/share/perl/5.38.2/autodie.pm (12436B)
package autodie; use 5.008; use strict; use warnings; use parent qw(Fatal); our $VERSION; # ABSTRACT: Replace functions with ones that succeed or die with lexical scope BEGIN { our $VERSION = '2.36'; # VERSION: Generated by DZP::OurPkg::Version } use constant ERROR_WRONG_FATAL => q{ Incorrect version of Fatal.pm loaded by autodie. The autodie pragma uses an updated version of Fatal to do its heavy lifting. We seem to have loaded Fatal version %s, which is probably the version that came with your version of Perl. However autodie needs version %s, which would have come bundled with autodie. You may be able to solve this problem by adding the following line of code to your main program, before any use of Fatal or autodie. use lib "%s"; }; # We have to check we've got the right version of Fatal before we # try to compile the rest of our code, lest we use a constant # that doesn't exist. BEGIN { # If we have the wrong Fatal, then we've probably loaded the system # one, not our own. Complain, and give a useful hint. ;) if (defined($Fatal::VERSION) and defined($VERSION) and $Fatal::VERSION ne $VERSION) { my $autodie_path = $INC{'autodie.pm'}; $autodie_path =~ s/autodie\.pm//; require Carp; Carp::croak sprintf( ERROR_WRONG_FATAL, $Fatal::VERSION, $VERSION, $autodie_path ); } } # When passing args to Fatal we want to keep the first arg # (our package) in place. Hence the splice. sub import { splice(@_,1,0,Fatal::LEXICAL_TAG); goto &Fatal::import; } sub unimport { splice(@_,1,0,Fatal::LEXICAL_TAG); goto &Fatal::unimport; } 1; __END__ =head1 NAME autodie - Replace functions with ones that succeed or die with lexical scope =head1 SYNOPSIS use autodie; # Recommended: implies 'use autodie qw(:default)' use autodie qw(:all); # Recommended more: defaults and system/exec. use autodie qw(open close); # open/close succeed or die open(my $fh, "<", $filename); # No need to check! { no autodie qw(open); # open failures won't die open(my $fh, "<", $filename); # Could fail silently! no autodie; # disable all autodies } print "Hello World" or die $!; # autodie DOESN'T check print! =head1 DESCRIPTION bIlujDI' yIchegh()Qo'; yIHegh()! It is better to die() than to return() in failure. -- Klingon programming proverb. The C pragma provides a convenient way to replace functions that normally return false on failure with equivalents that throw an exception on failure. The C pragma has I, meaning that functions and subroutines altered with C will only change their behaviour until the end of the enclosing block, file, or C. If C is specified as an argument to C, then it uses L to do the heavy lifting. See the description of that module for more information. =head1 EXCEPTIONS Exceptions produced by the C pragma are members of the L 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 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, C, C and C. 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 implies C. Note that C and C are not enabled by default. C requires the optional L module to be installed, and enabling C or C will invalidate their exotic forms. See L below for more details. The syntax: use autodie qw(:1.994); allows the C<:default> list from a particular version to be used. This provides the convenience of using the default methods, but the surety that no behavioral changes will occur if the C module is upgraded. C can be enabled for all of Perl's built-ins, including C and C with: use autodie qw(:all); =head1 FUNCTION SPECIFIC NOTES =head2 print The autodie pragma BZ<>>. =head2 flock It is not considered an error for C to return false if it fails due to an C (or equivalent) condition. This means one can still use the common convention of testing the return value of C when called with the C option: use autodie; if ( flock($fh, LOCK_EX | LOCK_NB) ) { # We have a lock } Autodying C will generate an exception if C returns false with any other error. =head2 system/exec The C built-in is considered to have failed in the following circumstances: =over 4 =item * The command does not start. =item * The command is killed by a signal. =item * The command returns a non-zero exit value (but see below). =back On success, the autodying form of C returns the I rather than the contents of C<$?>. Additional allowable exit values can be supplied as an optional first argument to autodying C: system( [ 0, 1, 2 ], $cmd, @args); # 0,1,2 are good exit values C uses the L module to change C. See its documentation for further information. Applying C to C or C causes the exotic forms C or C to be considered a syntax error until the end of the lexical scope. If you really need to use the exotic form, you can call C or C instead, or use C before calling the exotic form. =head1 GOTCHAS Functions called in list context are assumed to have failed if they return an empty list, or a list consisting only of a single undef element. Some builtins (e.g. C or C) has a call signature that cannot completely be represented with a Perl prototype. This means that some valid Perl code will be invalid under autodie. As an example: chdir(BAREWORD); Without autodie (and assuming BAREWORD is an open filehandle/dirhandle) this is a valid call to chdir. But under autodie, C will behave like it had the prototype ";$" and thus BAREWORD will be a syntax error (under "use strict". Without strict, it will interpreted as a filename). =head1 DIAGNOSTICS =over 4 =item :void cannot be used with lexical scope The C<:void> option is supported in L, but not C. To workaround this, C may be explicitly disabled until the end of the current block with C. To disable autodie for only a single function (eg, open) use C. C performs no checking of called context to determine whether to throw an exception; the explicitness of error handling with C is a deliberate feature. =item No user hints defined for %s You've insisted on hints for user-subroutines, either by pre-pending a C to the subroutine name itself, or earlier in the list of arguments to C. However the subroutine in question does not have any hints available. =back See also L. =head1 Tips and Tricks =head2 Importing autodie into another namespace than "caller" It is possible to import autodie into a different namespace by using L. However, you have to pass a "caller depth" (rather than a package name) for this to work correctly. =head1 BUGS "Used only once" warnings can be generated when C or C is used with package filehandles (eg, C). Scalar filehandles are strongly recommended instead. When using C or C with user subroutines, the declaration of those subroutines must appear before the first use of C or C, or have been exported from a module. Attempting to use C or C on other user subroutines will result in a compile-time error. Due to a bug in Perl, C may "lose" any format which has the same name as an autodying built-in or function. C may not work correctly if used inside a file with a name that looks like a string eval, such as F. =head2 autodie and string eval Due to the current implementation of C, unexpected results may be seen when used near or with the string version of eval. I. Under Perl 5.8 only, C I propagate into string C statements, although it can be explicitly enabled inside a string C. Under Perl 5.10 only, using a string eval when C is in effect can cause the autodie behaviour to leak into the surrounding scope. This can be worked around by using a C at the end of the scope to explicitly remove autodie's effects, or by avoiding the use of string eval. I. The use of C with block eval is considered good practice. =head2 REPORTING BUGS Please report bugs via the GitHub Issue Tracker at L. =head1 FEEDBACK If you find this module useful, please consider rating it on the CPAN Ratings service at L . The module author loves to hear how C has made your life better (or worse). Feedback can be sent to Epjf@perltraining.com.auE. =head1 AUTHOR Copyright 2008-2009, Paul Fenwick Epjf@perltraining.com.auE =head1 LICENSE This module is free software. You may distribute it under the same terms as Perl itself. =head1 SEE ALSO L, L, L, L I at L =head1 ACKNOWLEDGEMENTS Mark Reed and Roland Giersig -- Klingon translators. See the F file for full credits. The latest version of this file can be found at L . =cut