X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fautodie.pm;h=efb93d32bc5641bf8ae8d229a4640007d3345bbe;hb=d00e3d8a4128dcffa1eb58ae423543a07d0589f8;hp=38c12f9e8eac170785a6ebc3caff91027b485278;hpb=0b09a93a0cec34bc5d1740400c4ed9500d2f1dbe;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/autodie.pm b/lib/autodie.pm index 38c12f9..efb93d3 100644 --- a/lib/autodie.pm +++ b/lib/autodie.pm @@ -8,7 +8,7 @@ our @ISA = qw(Fatal); our $VERSION; BEGIN { - $VERSION = "1.997"; + $VERSION = '2.06'; } use constant ERROR_WRONG_FATAL => q{ @@ -73,7 +73,9 @@ autodie - Replace functions with ones that succeed or die with lexical scope =head1 SYNOPSIS - use autodie; # Recommended, implies 'use autodie qw(:default)' + 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 @@ -248,10 +250,15 @@ 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 surity +provides the convenience of using the default methods, but the surety that no behavorial 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 flock @@ -272,6 +279,36 @@ 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. @@ -292,10 +329,17 @@ element. =item :void cannot be used with lexical scope The C<:void> option is supported in L, but not -C. However you can explicitly disable autodie -end the end of the current block with C. +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 or C. +use C. + +=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 @@ -304,15 +348,40 @@ See also L. =head1 BUGS "Used only once" warnings can be generated when C or C -is used with package filehandles (eg, C). It's strongly recommended -you use scalar filehandles instead. +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 ue C or C on other user subroutines will +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 CPAN Request Tracker at @@ -330,7 +399,7 @@ Epjf@perltraining.com.auE. =head1 AUTHOR -Copyright 2008, Paul Fenwick Epjf@perltraining.com.auE +Copyright 2008-2009, Paul Fenwick Epjf@perltraining.com.auE =head1 LICENSE @@ -339,7 +408,7 @@ same terms as Perl itself. =head1 SEE ALSO -L, L, L +L, L, L, L I at L @@ -350,6 +419,6 @@ 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 . +L . =cut