diff options
author | Karl Berry <karl@freefriends.org> | 2019-03-10 21:56:14 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-03-10 21:56:14 +0000 |
commit | e0a2a718e89f9700d627f1e6a8eea8f21d2fbeb8 (patch) | |
tree | 39972f65008b0d70f306a5f976494d29411bc41e /Master/tlpkg/tlperl/lib/autodie | |
parent | b206fdc77d81ed1600949062f08de5690a4bf66f (diff) |
tl19 perl 5.28.1 for Windows, from Siep
git-svn-id: svn://tug.org/texlive/trunk@50322 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl/lib/autodie')
-rw-r--r-- | Master/tlpkg/tlperl/lib/autodie/exception.pm | 20 | ||||
-rw-r--r-- | Master/tlpkg/tlperl/lib/autodie/hints.pm | 19 |
2 files changed, 25 insertions, 14 deletions
diff --git a/Master/tlpkg/tlperl/lib/autodie/exception.pm b/Master/tlpkg/tlperl/lib/autodie/exception.pm index 73058085e00..8743719cb84 100644 --- a/Master/tlpkg/tlperl/lib/autodie/exception.pm +++ b/Master/tlpkg/tlperl/lib/autodie/exception.pm @@ -4,7 +4,7 @@ use strict; use warnings; use Carp qw(croak); -our $VERSION = '2.29'; # VERSION: Generated by DZP::OurPkg:Version +our $VERSION = '2.29002'; # ABSTRACT: Exceptions from autodying functions. our $DEBUG = 0; @@ -195,12 +195,10 @@ sub eval_error { return $_[0]->{$PACKAGE}{eval_error}; } if ( $e->matches('open') ) { ... } - if ( $e ~~ 'open' ) { ... } + if ( 'open' ~~ $e ) { ... } C<matches> is used to determine whether a -given exception matches a particular role. On Perl 5.10, -using smart-match (C<~~>) with an C<autodie::exception> object -will use C<matches> underneath. +given exception matches a particular role. An exception is considered to match a string if: @@ -221,6 +219,18 @@ C<CORE::open> subroutine does C<:file>, C<:io> and C<:all>. See L<autodie/CATEGORIES> for further information. +On Perl 5.10 and above, using smart-match (C<~~>) with an +C<autodie::exception> object will use C<matches> underneath. This module +used to recommend using smart-match with the exception object on the left +hand side, but in future Perls that is likely to stop working. +The smart-match facility of this class should only be used with the +exception object on the right hand side. Having the exception object on +the right is both future-proof and portable to older Perls, back to 5.10. +Beware that this facility can only +be relied upon when it is certain that the exception object actually is +an C<autodie::exception> object; it is no more capable than an explicit +call to the C<matches> method. + =back =cut diff --git a/Master/tlpkg/tlperl/lib/autodie/hints.pm b/Master/tlpkg/tlperl/lib/autodie/hints.pm index beaefcc28a9..be9fbceb475 100644 --- a/Master/tlpkg/tlperl/lib/autodie/hints.pm +++ b/Master/tlpkg/tlperl/lib/autodie/hints.pm @@ -5,7 +5,7 @@ use warnings; use constant PERL58 => ( $] < 5.009 ); -our $VERSION = '2.29'; # VERSION: Generated by DZP::OurPkg:Version +our $VERSION = '2.29001'; # ABSTRACT: Provide hints about user subroutines to autodie @@ -115,8 +115,9 @@ has been checked. =head2 Example hints -Hints may consist of scalars, array references, regular expressions and -subroutine references. You can specify different hints for how +Hints may consist of subroutine references, objects overloading +smart-match, regular expressions, and depending on Perl version possibly +other things. You can specify different hints for how failure should be identified in scalar and list contexts. These examples apply for use in the C<AUTODIE_HINTS> subroutine and when @@ -125,16 +126,16 @@ calling C<autodie::hints->set_hints_for()>. The most common context-specific hints are: # Scalar failures always return undef: - { scalar => undef } + { scalar => sub { !defined($_[0]) } } # Scalar failures return any false value [default expectation]: { scalar => sub { ! $_[0] } } # Scalar failures always return zero explicitly: - { scalar => '0' } + { scalar => sub { defined($_[0]) && $_[0] eq '0' } } # List failures always return an empty list: - { list => [] } + { list => sub { !@_ } } # List failures return () or (undef) [default expectation]: { list => sub { ! @_ || @_ == 1 && !defined $_[0] } } @@ -151,7 +152,7 @@ The most common context-specific hints are: \&foo, { scalar => qr/^ _? FAIL $/xms, - list => [-1], + list => sub { @_ == 1 && $_[0] eq -1 }, } ); @@ -159,8 +160,8 @@ The most common context-specific hints are: autodie::hints->set_hints_for( \&foo, { - scalar => 0, - list => [0], + scalar => sub { defined($_[0]) && $_[0] == 0 }, + list => sub { @_ == 1 && defined($_[0]) && $_[0] == 0 }, } ); |