argra****@users*****
argra****@users*****
2011年 9月 7日 (水) 03:05:06 JST
Index: docs/modules/autodie-2.06_01/Fatal.pod diff -u /dev/null docs/modules/autodie-2.06_01/Fatal.pod:1.1 --- /dev/null Wed Sep 7 03:05:06 2011 +++ docs/modules/autodie-2.06_01/Fatal.pod Wed Sep 7 03:05:05 2011 @@ -0,0 +1,290 @@ + +=encoding euc-jp + +=head1 NAME + +=begin original + +Fatal - Replace functions with equivalents which succeed or die + +=end original + +Fatal - 関数を、成功しなければ die する等価物に置き換える + +=head1 SYNOPSIS + + use Fatal qw(open close); + + open(my $fh, "<", $filename); # No need to check errors! + + use File::Copy qw(move); + use Fatal qw(move); + + move($file1, $file2); # No need to check errors! + + sub juggle { . . . } + Fatal->import('juggle'); + +=head1 BEST PRACTICE + +=begin original + +B<Fatal has been obsoleted by the new L<autodie> pragma.> Please use +L<autodie> in preference to C<Fatal>. L<autodie> supports lexical scoping, +throws real exception objects, and provides much nicer error messages. + +=end original + +B<Fatal は新しい L<autodie> プラグマによって古いものになりました。> +C<Fatal> よりも L<autodie> を使ってください。 +L<autodie> はレキシカルスコープに対応し、実例外オブジェクトを投げ、 +遥かによいエラーメッセージを提供します。 + +=begin original + +The use of C<:void> with Fatal is discouraged. + +=end original + +Fatal での C<:void> の仕様は非推奨です。 + +=head1 DESCRIPTION + +=begin original + +C<Fatal> provides a way to conveniently replace +functions which normally return a false value when they fail with +equivalents which raise exceptions if they are not successful. This +lets you use these functions without having to test their return +values explicitly on each call. Exceptions can be caught using +C<eval{}>. See L<perlfunc> and L<perlvar> for details. + +=end original + +C<Fatal> provides a way to conveniently replace +functions which normally return a false value when they fail with +equivalents which raise exceptions if they are not successful. This +lets you use these functions without having to test their return +values explicitly on each call. Exceptions can be caught using +C<eval{}>. See L<perlfunc> and L<perlvar> for details. +(TBT) + +=begin original + +The do-or-die equivalents are set up simply by calling Fatal's +C<import> routine, passing it the names of the functions to be +replaced. You may wrap both user-defined functions and overridable +CORE operators (except C<exec>, C<system>, C<print>, or any other +built-in that cannot be expressed via prototypes) in this way. + +=end original + +The do-or-die equivalents are set up simply by calling Fatal's +C<import> routine, passing it the names of the functions to be +replaced. You may wrap both user-defined functions and overridable +CORE operators (except C<exec>, C<system>, C<print>, or any other +built-in that cannot be expressed via prototypes) in this way. +(TBT) + +=begin original + +If the symbol C<:void> appears in the import list, then functions +named later in that import list raise an exception only when +these are called in void context--that is, when their return +values are ignored. For example + +=end original + +If the symbol C<:void> appears in the import list, then functions +named later in that import list raise an exception only when +these are called in void context--that is, when their return +values are ignored. For example +(TBT) + + use Fatal qw/:void open close/; + + # properly checked, so no exception raised on error + if (not open(my $fh, '<', '/bogotic') { + warn "Can't open /bogotic: $!"; + } + + # not checked, so error raises an exception + close FH; + +=begin original + +The use of C<:void> is discouraged, as it can result in exceptions +not being thrown if you I<accidentally> call a method without +void context. Use L<autodie> instead if you need to be able to +disable autodying/Fatal behaviour for a small block of code. + +=end original + +The use of C<:void> is discouraged, as it can result in exceptions +not being thrown if you I<accidentally> call a method without +void context. Use L<autodie> instead if you need to be able to +disable autodying/Fatal behaviour for a small block of code. +(TBT) + +=head1 DIAGNOSTICS + +=over 4 + +=item Bad subroutine name for Fatal: %s + +=begin original + +You've called C<Fatal> with an argument that doesn't look like +a subroutine name, nor a switch that this version of Fatal +understands. + +=end original + +You've called C<Fatal> with an argument that doesn't look like +a subroutine name, nor a switch that this version of Fatal +understands. +(TBT) + +=item %s is not a Perl subroutine + +=begin original + +You've asked C<Fatal> to try and replace a subroutine which does not +exist, or has not yet been defined. + +=end original + +You've asked C<Fatal> to try and replace a subroutine which does not +exist, or has not yet been defined. +(TBT) + +=item %s is neither a builtin, nor a Perl subroutine + +=begin original + +You've asked C<Fatal> to replace a subroutine, but it's not a Perl +built-in, and C<Fatal> couldn't find it as a regular subroutine. +It either doesn't exist or has not yet been defined. + +=end original + +You've asked C<Fatal> to replace a subroutine, but it's not a Perl +built-in, and C<Fatal> couldn't find it as a regular subroutine. +It either doesn't exist or has not yet been defined. +(TBT) + +=item Cannot make the non-overridable %s fatal + +=begin original + +You've tried to use C<Fatal> on a Perl built-in that can't be +overridden, such as C<print> or C<system>, which means that +C<Fatal> can't help you, although some other modules might. +See the L</"SEE ALSO"> section of this documentation. + +=end original + +You've tried to use C<Fatal> on a Perl built-in that can't be +overridden, such as C<print> or C<system>, which means that +C<Fatal> can't help you, although some other modules might. +See the L</"SEE ALSO"> section of this documentation. +(TBT) + +=item Internal error: %s + +=begin original + +You've found a bug in C<Fatal>. Please report it using +the C<perlbug> command. + +=end original + +You've found a bug in C<Fatal>. Please report it using +the C<perlbug> command. +(TBT) + +=back + +=head1 BUGS + +=begin original + +C<Fatal> clobbers the context in which a function is called and always +makes it a scalar context, except when the C<:void> tag is used. +This problem does not exist in L<autodie>. + +=end original + +C<Fatal> clobbers the context in which a function is called and always +makes it a scalar context, except when the C<:void> tag is used. +This problem does not exist in L<autodie>. +(TBT) + +=begin original + +"Used only once" warnings can be generated when C<autodie> or C<Fatal> +is used with package filehandles (eg, C<FILE>). It's strongly recommended +you use scalar filehandles instead. + +=end original + +"Used only once" warnings can be generated when C<autodie> or C<Fatal> +is used with package filehandles (eg, C<FILE>). It's strongly recommended +you use scalar filehandles instead. +(TBT) + +=head1 AUTHOR + +=begin original + +Original module by Lionel Cons (CERN). + +=end original + +元のモジュールは Lionel Cons (CERN)。 + +=begin original + +Prototype updates by Ilya Zakharevich <ilya****@math*****>. + +=end original + +プロトタイプの更新は Ilya Zakharevich <ilya****@math*****>。 + +=begin original + +L<autodie> support, bugfixes, extended diagnostics, C<system> +support, and major overhauling by Paul Fenwick <pjf****@perlt*****> + +=end original + +L<autodie> 対応、バグ修正、診断メッセージの拡張、C<system> 対応、 +大幅なオーバーホールは Paul Fenwick <pjf****@perlt*****>。 + +=head1 LICENSE + +This module is free software, you may distribute it under the +same terms as Perl itself. + +=head1 SEE ALSO + +=begin original + +L<autodie> for a nicer way to use lexical Fatal. + +=end original + +レキシカルに Fatal をつかうよりよい方法である L<autodie>。 + +=begin original + +L<IPC::System::Simple> for a similar idea for calls to C<system()> +and backticks. + +=end original + +C<system()> と逆クォートに関する似たようなアイデアである +L<IPC::System::Simple>。 + +=cut + Index: docs/modules/autodie-2.06_01/autodie.pod diff -u /dev/null docs/modules/autodie-2.06_01/autodie.pod:1.1 --- /dev/null Wed Sep 7 03:05:06 2011 +++ docs/modules/autodie-2.06_01/autodie.pod Wed Sep 7 03:05:05 2011 @@ -0,0 +1,699 @@ + +=encoding euc-jp + +=head1 NAME + +=begin original + +autodie - Replace functions with ones that succeed or die with lexical scope + +=end original + +autodie - レキシカルスコープ内の関数を、成功しなければ die するものに置き換える + +=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 + } + +=head1 DESCRIPTION + + bIlujDI' yIchegh()Qo'; yIHegh()! + + It is better to die() than to return() in failure. + + -- Klingon programming proverb. + +=begin original + +The C<autodie> pragma provides a convenient way to replace functions +that normally return false on failure with equivalents that throw +an exception on failure. + +=end original + +The C<autodie> pragma provides a convenient way to replace functions +that normally return false on failure with equivalents that throw +an exception on failure. +(TBT) + +=begin original + +The C<autodie> pragma has I<lexical scope>, meaning that functions +and subroutines altered with C<autodie> will only change their behaviour +until the end of the enclosing block, file, or C<eval>. + +=end original + +The C<autodie> pragma has I<lexical scope>, meaning that functions +and subroutines altered with C<autodie> will only change their behaviour +until the end of the enclosing block, file, or C<eval>. +(TBT) + +=begin original + +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. + +=end original + +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. +(TBT) + +=head1 EXCEPTIONS + +=begin original + +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: + +=end original + +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: +(TBT) + + use feature qw(switch); + + eval { + use autodie; + + open(my $fh, '<', $some_file); + + my @records = <$fh>; + + # Do things with @records... + + close($fh); + + }; + + given ($@) { + when (undef) { say "No error"; } + when ('open') { say "Error from open"; } + when (':io') { say "Non-open, IO error."; } + when (':all') { say "All other autodie errors." } + default { say "Not an autodie error at all." } + } + +=begin original + +Under Perl 5.8, the C<given/when> structure is not available, so the +following structure may be used: + +=end original + +Under Perl 5.8, the C<given/when> structure is not available, so the +following structure may be used: +(TBT) + + 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. + } + +=begin original + +See L<autodie::exception> for further information on interrogating +exceptions. + +=end original + +See L<autodie::exception> for further information on interrogating +exceptions. +(TBT) + +=head1 CATEGORIES + +=begin original + +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<fileno>, C<open> and C<sysopen>. + +=end original + +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<fileno>, C<open> and C<sysopen>. +(TBT) + +=begin original + +The categories are currently: + +=end original + +The categories are currently: +(TBT) + + :all + :default + :io + read + seek + sysread + sysseek + syswrite + :dbm + dbmclose + dbmopen + :file + binmode + close + fcntl + fileno + flock + ioctl + open + sysopen + truncate + :filesys + chdir + closedir + opendir + link + mkdir + readlink + rename + rmdir + symlink + unlink + :ipc + 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 + + +=begin original + +Note that while the above category system is presently a strict +hierarchy, this should not be assumed. + +=end original + +Note that while the above category system is presently a strict +hierarchy, this should not be assumed. +(TBT) + +=begin original + +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. + +=end original + +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. +(TBT) + +=begin original + +The syntax: + +=end original + +The syntax: +(TBT) + + use autodie qw(:1.994); + +=begin original + +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 behavorial changes will occur if the C<autodie> module is +upgraded. + +=end original + +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 behavorial changes will occur if the C<autodie> module is +upgraded. +(TBT) + +=begin original + +C<autodie> can be enabled for all of Perl's built-ins, including +C<system> and C<exec> with: + +=end original + +C<autodie> can be enabled for all of Perl's built-ins, including +C<system> and C<exec> with: +(TBT) + + use autodie qw(:all); + +=head1 FUNCTION SPECIFIC NOTES + +=head2 flock + +=begin original + +It is not considered an error for C<flock> to return false if it fails +to an C<EWOULDBLOCK> (or equivalent) condition. This means one can +still use the common convention of testing the return value of +C<flock> when called with the C<LOCK_NB> option: + +=end original + +It is not considered an error for C<flock> to return false if it fails +to an C<EWOULDBLOCK> (or equivalent) condition. This means one can +still use the common convention of testing the return value of +C<flock> when called with the C<LOCK_NB> option: +(TBT) + + use autodie; + + if ( flock($fh, LOCK_EX | LOCK_NB) ) { + # We have a lock + } + +=begin original + +Autodying C<flock> will generate an exception if C<flock> returns +false with any other error. + +=end original + +Autodying C<flock> will generate an exception if C<flock> returns +false with any other error. +(TBT) + +=head2 system/exec + +=begin original + +The C<system> built-in is considered to have failed in the following +circumstances: + +=end original + +The C<system> built-in is considered to have failed in the following +circumstances: +(TBT) + +=over 4 + +=item * + +=begin original + +The command does not start. + +=end original + +The command does not start. +(TBT) + +=item * + +=begin original + +The command is killed by a signal. + +=end original + +The command is killed by a signal. +(TBT) + +=item * + +=begin original + +The command returns a non-zero exit value (but see below). + +=end original + +The command returns a non-zero exit value (but see below). +(TBT) + +=back + +=begin original + +On success, the autodying form of C<system> returns the I<exit value> +rather than the contents of C<$?>. + +=end original + +On success, the autodying form of C<system> returns the I<exit value> +rather than the contents of C<$?>. +(TBT) + +=begin original + +Additional allowable exit values can be supplied as an optional first +argument to autodying C<system>: + +=end original + +Additional allowable exit values can be supplied as an optional first +argument to autodying C<system>: +(TBT) + + system( [ 0, 1, 2 ], $cmd, @args); # 0,1,2 are good exit values + +=begin original + +C<autodie> uses the L<IPC::System::Simple> module to change C<system>. +See its documentation for further information. + +=end original + +C<autodie> uses the L<IPC::System::Simple> module to change C<system>. +See its documentation for further information. +(TBT) + +=begin original + +Applying C<autodie> to C<system> or C<exec> causes the exotic +forms C<system { $cmd } @args > or C<exec { $cmd } @args> +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<CORE::system> +or C<CORE::exec> instead, or use C<no autodie qw(system exec)> before +calling the exotic form. + +=end original + +Applying C<autodie> to C<system> or C<exec> causes the exotic +forms C<system { $cmd } @args > or C<exec { $cmd } @args> +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<CORE::system> +or C<CORE::exec> instead, or use C<no autodie qw(system exec)> before +calling the exotic form. +(TBT) + +=head1 GOTCHAS + +=begin original + +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. + +=end original + +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. +(TBT) + +=head1 DIAGNOSTICS + +=over 4 + +=item :void cannot be used with lexical scope + +=begin original + +The C<:void> option is supported in L<Fatal>, but not +C<autodie>. To workaround this, C<autodie> may be explicitly disabled until +the end of the current block with C<no autodie>. +To disable autodie for only a single function (eg, open) +use C<no autodie qw(open)>. + +=end original + +The C<:void> option is supported in L<Fatal>, but not +C<autodie>. To workaround this, C<autodie> may be explicitly disabled until +the end of the current block with C<no autodie>. +To disable autodie for only a single function (eg, open) +use C<no autodie qw(open)>. +(TBT) + +=item No user hints defined for %s + +=begin original + +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<autodie>. However the subroutine in question does not have +any hints available. + +=end original + +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<autodie>. However the subroutine in question does not have +any hints available. +(TBT) + +=back + +=begin original + +See also L<Fatal/DIAGNOSTICS>. + +=end original + +See also L<Fatal/DIAGNOSTICS>. +(TBT) + +=head1 BUGS + +=begin original + +"Used only once" warnings can be generated when C<autodie> or C<Fatal> +is used with package filehandles (eg, C<FILE>). Scalar filehandles are +strongly recommended instead. + +=end original + +"Used only once" warnings can be generated when C<autodie> or C<Fatal> +is used with package filehandles (eg, C<FILE>). Scalar filehandles are +strongly recommended instead. +(TBT) + +=begin original + +When using C<autodie> or C<Fatal> with user subroutines, the +declaration of those subroutines must appear before the first use of +C<Fatal> or C<autodie>, or have been exported from a module. +Attempting to use C<Fatal> or C<autodie> on other user subroutines will +result in a compile-time error. + +=end original + +When using C<autodie> or C<Fatal> with user subroutines, the +declaration of those subroutines must appear before the first use of +C<Fatal> or C<autodie>, or have been exported from a module. +Attempting to use C<Fatal> or C<autodie> on other user subroutines will +result in a compile-time error. +(TBT) + +=begin original + +Due to a bug in Perl, C<autodie> may "lose" any format which has the +same name as an autodying built-in or function. + +=end original + +Due to a bug in Perl, C<autodie> may "lose" any format which has the +same name as an autodying built-in or function. +(TBT) + +=begin original + +C<autodie> may not work correctly if used inside a file with a +name that looks like a string eval, such as F<eval (3)>. + +=end original + +C<autodie> may not work correctly if used inside a file with a +name that looks like a string eval, such as F<eval (3)>. +(TBT) + +=head2 autodie and string eval + +=begin original + +Due to the current implementation of C<autodie>, unexpected results +may be seen when used near or with the string version of eval. +I<None of these bugs exist when using block eval>. + +=end original + +Due to the current implementation of C<autodie>, unexpected results +may be seen when used near or with the string version of eval. +I<None of these bugs exist when using block eval>. +(TBT) + +=begin original + +Under Perl 5.8 only, C<autodie> I<does not> propagate into string C<eval> +statements, although it can be explicitly enabled inside a string +C<eval>. + +=end original + +Under Perl 5.8 only, C<autodie> I<does not> propagate into string C<eval> +statements, although it can be explicitly enabled inside a string +C<eval>. +(TBT) + +=begin original + +Under Perl 5.10 only, using a string eval when C<autodie> is in +effect can cause the autodie behaviour to leak into the surrounding +scope. This can be worked around by using a C<no autodie> at the +end of the scope to explicitly remove autodie's effects, or by +avoiding the use of string eval. + +=end original + +Under Perl 5.10 only, using a string eval when C<autodie> is in +effect can cause the autodie behaviour to leak into the surrounding +scope. This can be worked around by using a C<no autodie> at the +end of the scope to explicitly remove autodie's effects, or by +avoiding the use of string eval. +(TBT) + +=begin original + +I<None of these bugs exist when using block eval>. The use of +C<autodie> with block eval is considered good practice. + +=end original + +I<None of these bugs exist when using block eval>. The use of +C<autodie> with block eval is considered good practice. +(TBT) + +=head2 REPORTING BUGS + +=begin original + +Please report bugs via the CPAN Request Tracker at +L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=autodie>. + +=end original + +Please report bugs via the CPAN Request Tracker at +L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=autodie>. +(TBT) + +=head1 FEEDBACK + +=begin original + +If you find this module useful, please consider rating it on the +CPAN Ratings service at +L<http://cpanratings.perl.org/rate?distribution=autodie> . + +=end original + +If you find this module useful, please consider rating it on the +CPAN Ratings service at +L<http://cpanratings.perl.org/rate?distribution=autodie> . +(TBT) + +=begin original + +The module author loves to hear how C<autodie> has made your life +better (or worse). Feedback can be sent to +E<lt>pjf****@perlt*****<gt>. + +=end original + +The module author loves to hear how C<autodie> has made your life +better (or worse). Feedback can be sent to +E<lt>pjf****@perlt*****<gt>. +(TBT) + +=head1 AUTHOR + +Copyright 2008-2009, Paul Fenwick E<lt>pjf****@perlt*****<gt> + +=head1 LICENSE + +This module is free software. You may distribute it under the +same terms as Perl itself. + + +=head1 SEE ALSO + +L<Fatal>, L<autodie::exception>, L<autodie::hints>, L<IPC::System::Simple> + +I<Perl tips, autodie> at +L<http://perltraining.com.au/tips/2008-08-20.html> + +=head1 ACKNOWLEDGEMENTS + +Mark Reed and Roland Giersig -- Klingon translators. + +See the F<AUTHORS> file for full credits. The latest version of this +file can be found at +L<http://github.com/pfenwick/autodie/tree/master/AUTHORS> . + +=cut +