11195Srgrimespackage autodie::hints; 23992Sphk 337Srgrimesuse strict; 437Srgrimesuse warnings; 537Srgrimes 6147Srgrimesuse constant PERL58 => ( $] < 5.009 ); 7147Srgrimes 83017Srgrimesour $VERSION = '2.36'; # VERSION: Generated by DZP::OurPkg:Version 93017Srgrimes 103017Srgrimes# ABSTRACT: Provide hints about user subroutines to autodie 113161Sache 123654Sphk=head1 NAME 133017Srgrimes 141734Sjkhautodie::hints - Provide hints about user subroutines to autodie 151734Sjkh 1637Srgrimes=head1 SYNOPSIS 1737Srgrimes 1837Srgrimes package Your::Module; 1937Srgrimes 201773Sjkh our %DOES = ( 'autodie::hints::provider' => 1 ); 21147Srgrimes 22147Srgrimes sub AUTODIE_HINTS { 232779Srgrimes return { 242779Srgrimes foo => { scalar => HINTS, list => SOME_HINTS }, 252779Srgrimes bar => { scalar => HINTS, list => MORE_HINTS }, 261767Sjkh } 272570Srgrimes } 282570Srgrimes 292570Srgrimes # Later, in your main program... 302570Srgrimes 312570Srgrimes use Your::Module qw(foo bar); 322570Srgrimes use autodie qw(:default foo bar); 332570Srgrimes 342570Srgrimes foo(); # succeeds or dies based on scalar hints 351782Sjkh 361782Sjkh # Alternatively, hints can be set on subroutines we've 37491Srgrimes # imported. 3837Srgrimes 3937Srgrimes use autodie::hints; 4037Srgrimes use Some::Module qw(think_positive); 4137Srgrimes 4237Srgrimes BEGIN { 43263Srgrimes autodie::hints->set_hints_for( 442779Srgrimes \&think_positive, 452779Srgrimes { 46993Srgrimes fail => sub { $_[0] <= 0 } 47277Srgrimes } 482779Srgrimes ) 49284Srgrimes } 50463Srgrimes use autodie qw(think_positive); 513607Sphk 523607Sphk think_positive(...); # Returns positive or dies. 532779Srgrimes 54284Srgrimes 55284Srgrimes=head1 DESCRIPTION 56284Srgrimes 57284Srgrimes=head2 Introduction 58284Srgrimes 593647SphkThe L<autodie> pragma is very smart when it comes to working with 60284SrgrimesPerl's built-in functions. The behaviour for these functions are 611767Sjkhfixed, and C<autodie> knows exactly how they try to signal failure. 621285Srgrimes 632499SgpalmerBut what about user-defined subroutines from modules? If you use 641285SrgrimesC<autodie> on a user-defined subroutine then it assumes the following 65284Srgrimesbehaviour to demonstrate failure: 661371Srgrimes 671371Srgrimes=over 681194Srgrimes 69358Srgrimes=item * 70358Srgrimes 71412SalmA false value, in scalar context 72358Srgrimes 73452Srgrimes=item * 74358Srgrimes 751194SrgrimesAn empty list, in list context 761767Sjkh 771194Srgrimes=item * 782779Srgrimes 791194SrgrimesA list containing a single undef, in list context 801194Srgrimes 811194Srgrimes=back 821194Srgrimes 831194SrgrimesAll other return values (including the list of the single zero, and the 841194Srgrimeslist containing a single empty string) are considered successful. However, 851194Srgrimesreal-world code isn't always that easy. Perhaps the code you're working 861194Srgrimeswith returns a string containing the word "FAIL" upon failure, or a 871194Srgrimestwo element list containing C<(undef, "human error message")>. To make 881194Srgrimesautodie work with these sorts of subroutines, we have 891194Srgrimesthe I<hinting interface>. 901194Srgrimes 911194SrgrimesThe hinting interface allows I<hints> to be provided to C<autodie> 922779Srgrimeson how it should detect failure from user-defined subroutines. While 931194Srgrimesthese I<can> be provided by the end-user of C<autodie>, they are ideally 941194Srgrimeswritten into the module itself, or into a helper module or sub-class 951243Srgrimesof C<autodie> itself. 96263Srgrimes 97358Srgrimes=head2 What are hints? 981194Srgrimes 991194SrgrimesA I<hint> is a subroutine or value that is checked against the 1001194Srgrimesreturn value of an autodying subroutine. If the match returns true, 1011773SjkhC<autodie> considers the subroutine to have failed. 1022499Sgpalmer 1031194SrgrimesIf the hint provided is a subroutine, then C<autodie> will pass 104452Srgrimesthe complete return value to that subroutine. If the hint is 1051194Srgrimesany other value, then C<autodie> will smart-match against the 1061194Srgrimesvalue provided. In Perl 5.8.x there is no smart-match operator, and as such 107358Srgrimesonly subroutine hints are supported in these versions. 1081194Srgrimes 1092779SrgrimesHints can be provided for both scalar and list contexts. Note 1102779Srgrimesthat an autodying subroutine will never see a void context, as 1112779SrgrimesC<autodie> always needs to capture the return value for examination. 1122779SrgrimesAutodying subroutines called in void context act as if they're called 1132779Srgrimesin a scalar context, but their return value is discarded after it 1142779Srgrimeshas been checked. 1151243Srgrimes 1161194Srgrimes=head2 Example hints 1171194Srgrimes 1181243SrgrimesHints may consist of subroutine references, objects overloading 1191243Srgrimessmart-match, regular expressions, and depending on Perl version possibly 120284Srgrimesother things. You can specify different hints for how 1212570Srgrimesfailure should be identified in scalar and list contexts. 1222570Srgrimes 123372SrgrimesThese examples apply for use in the C<AUTODIE_HINTS> subroutine and when 1242570Srgrimescalling C<< autodie::hints->set_hints_for() >>. 1253992Sphk 1262779SrgrimesThe most common context-specific hints are: 1273992Sphk 1282779Srgrimes # Scalar failures always return undef: 129347Srgrimes { scalar => sub { !defined($_[0]) } } 1301767Sjkh 13137Srgrimes # Scalar failures return any false value [default expectation]: 1322538Spst { scalar => sub { ! $_[0] } } 133347Srgrimes 1342538Spst # Scalar failures always return zero explicitly: 135355Srgrimes { scalar => sub { defined($_[0]) && $_[0] eq '0' } } 136372Srgrimes 137347Srgrimes # List failures always return an empty list: 138355Srgrimes { list => sub { !@_ } } 139347Srgrimes 1402538Spst # List failures return () or (undef) [default expectation]: 1412538Spst { list => sub { ! @_ || @_ == 1 && !defined $_[0] } } 1422538Spst 1432538Spst # List failures return () or a single false value: 1442538Spst { list => sub { ! @_ || @_ == 1 && !$_[0] } } 145372Srgrimes 146347Srgrimes # List failures return (undef, "some string") 147355Srgrimes { list => sub { @_ == 2 && !defined $_[0] } } 148347Srgrimes 149347Srgrimes # Unsuccessful foo() returns 'FAIL' or '_FAIL' in scalar context, 1502538Spst # returns (-1) in list context... 151147Srgrimes autodie::hints->set_hints_for( 1521759Sjkh \&foo, 1531759Sjkh { 1541759Sjkh scalar => qr/^ _? FAIL $/xms, 1551759Sjkh list => sub { @_ == 1 && $_[0] eq -1 }, 1561759Sjkh } 1571731Sjkh ); 1581759Sjkh 1591731Sjkh # Unsuccessful foo() returns 0 in all contexts... 1601759Sjkh autodie::hints->set_hints_for( 1611759Sjkh \&foo, 16237Srgrimes { 1631759Sjkh scalar => sub { defined($_[0]) && $_[0] == 0 }, 1641759Sjkh list => sub { @_ == 1 && defined($_[0]) && $_[0] == 0 }, 1651731Sjkh } 1661731Sjkh ); 16737Srgrimes 1681731SjkhThis "in all contexts" construction is very common, and can be 16937Srgrimesabbreviated, using the 'fail' key. This sets both the C<scalar> 1701731Sjkhand C<list> hints to the same value: 17137Srgrimes 1721731Sjkh # Unsuccessful foo() returns 0 in all contexts... 17337Srgrimes autodie::hints->set_hints_for( 17437Srgrimes \&foo, 17537Srgrimes { 17637Srgrimes fail => sub { @_ == 1 and defined $_[0] and $_[0] == 0 } 1771731Sjkh } 1781731Sjkh ); 1791731Sjkh 1801731Sjkh # Unsuccessful think_positive() returns negative number on failure... 18137Srgrimes autodie::hints->set_hints_for( 18237Srgrimes \&think_positive, 183147Srgrimes { 184147Srgrimes fail => sub { $_[0] < 0 } 18537Srgrimes } 186147Srgrimes ); 18737Srgrimes 18837Srgrimes # Unsuccessful my_system() returns non-zero on failure... 18937Srgrimes autodie::hints->set_hints_for( 190288Srgrimes \&my_system, 191288Srgrimes { 192147Srgrimes fail => sub { $_[0] != 0 } 19337Srgrimes } 194147Srgrimes ); 195147Srgrimes 19637Srgrimes=head1 Manually setting hints from within your program 1971759Sjkh 1981759SjkhIf you are using a module which returns something special on failure, then 1991759Sjkhyou can manually create hints for each of the desired subroutines. Once 2001759Sjkhthe hints are specified, they are available for all files and modules loaded 201347Srgrimesthereafter, thus you can move this work into a module and it will still 2022538Spstwork. 2032538Spst 204347Srgrimes use Some::Module qw(foo bar); 2052538Spst use autodie::hints; 2061775Sjkh 207347Srgrimes autodie::hints->set_hints_for( 2081759Sjkh \&foo, 209355Srgrimes { 210277Srgrimes scalar => SCALAR_HINT, 2111126Srgrimes list => LIST_HINT, 2121126Srgrimes } 2131731Sjkh ); 214238Sroot autodie::hints->set_hints_for( 2151759Sjkh \&bar, 2161731Sjkh { fail => SOME_HINT, } 2171759Sjkh ); 218333Srgrimes 2191759SjkhIt is possible to pass either a subroutine reference (recommended) or a fully 2201759Sjkhqualified subroutine name as the first argument. This means you can set hints 221168Srgrimeson modules that I<might> get loaded: 222333Srgrimes 2231759Sjkh use autodie::hints; 2241759Sjkh autodie::hints->set_hints_for( 225333Srgrimes 'Some::Module:bar', { fail => SCALAR_HINT, } 22637Srgrimes ); 2271731Sjkh 2282619SrgrimesThis technique is most useful when you have a project that uses a 2291782Sjkhlot of third-party modules. You can define all your possible hints 2302619Srgrimesin one-place. This can even be in a sub-class of autodie. For 2311782Sjkhexample: 2321731Sjkh 2331731Sjkh package my::autodie; 2341731Sjkh 2352570Srgrimes use parent qw(autodie); 2362570Srgrimes use autodie::hints; 2371731Sjkh 2382570Srgrimes autodie::hints->set_hints_for(...); 2392570Srgrimes 2401731Sjkh 1; 2412570Srgrimes 2422570SrgrimesYou can now C<use my::autodie>, which will work just like the standard 2431731SjkhC<autodie>, but is now aware of any hints that you've set. 24437Srgrimes 2451759Sjkh=head1 Adding hints to your module 2461759Sjkh 24737SrgrimesC<autodie> provides a passive interface to allow you to declare hints for 2483764Sphkyour module. These hints will be found and used by C<autodie> if it 2493764Sphkis loaded, but otherwise have no effect (or dependencies) without autodie. 2503764SphkTo set these, your module needs to declare that it I<does> the 2513764SphkC<autodie::hints::provider> role. This can be done by writing your 2522779Srgrimesown C<DOES> method, using a system such as C<Class::DOES> to handle 2533764Sphkthe heavy-lifting for you, or declaring a C<%DOES> package variable 254320Srgrimeswith a C<autodie::hints::provider> key and a corresponding true value. 255358Srgrimes 2563607SphkNote that checking for a C<%DOES> hash is an C<autodie>-only 2572779Srgrimesshort-cut. Other modules do not use this mechanism for checking 2582779Srgrimesroles, although you can use the C<Class::DOES> module from the 2591762SjkhCPAN to allow it. 2601027Sache 2611027SacheIn addition, you must define a C<AUTODIE_HINTS> subroutine that returns 2621731Sjkha hash-reference containing the hints for your subroutines: 263333Srgrimes 264284Srgrimes package Your::Module; 265320Srgrimes 2662570Srgrimes # We can use the Class::DOES from the CPAN to declare adherence 267284Srgrimes # to a role. 268320Srgrimes 2691731Sjkh use Class::DOES 'autodie::hints::provider' => 1; 2703647Sphk 2711731Sjkh # Alternatively, we can declare the role in %DOES. Note that 2721762Sjkh # this is an autodie specific optimisation, although Class::DOES 2731194Srgrimes # can be used to promote this to a true role declaration. 2741194Srgrimes 2751194Srgrimes our %DOES = ( 'autodie::hints::provider' => 1 ); 2761194Srgrimes 277320Srgrimes # Finally, we must define the hints themselves. 2783764Sphk 2792570Srgrimes sub AUTODIE_HINTS { 2803764Sphk return { 2812779Srgrimes foo => { scalar => HINTS, list => SOME_HINTS }, 282277Srgrimes bar => { scalar => HINTS, list => MORE_HINTS }, 2832779Srgrimes baz => { fail => HINTS }, 2842779Srgrimes } 2851027Sache } 2863764Sphk 2872779SrgrimesThis allows your code to set hints without relying on C<autodie> and 2883764SphkC<autodie::hints> being loaded, or even installed. In this way your 2893764Sphkcode can do the right thing when C<autodie> is installed, but does not 290277Srgrimesneed to depend upon it to function. 2911285Srgrimes 2922570Srgrimes=head1 Insisting on hints 2931371Srgrimes 2941371SrgrimesWhen a user-defined subroutine is wrapped by C<autodie>, it will 2951371Srgrimesuse hints if they are available, and otherwise reverts to the 2961371SrgrimesI<default behaviour> described in the introduction of this document. 2971371SrgrimesThis can be problematic if we expect a hint to exist, but (for 2981285Srgrimeswhatever reason) it has not been loaded. 2991731Sjkh 3001285SrgrimesWe can ask autodie to I<insist> that a hint be used by prefixing 3013647Sphkan exclamation mark to the start of the subroutine name. A lone 3023647Sphkexclamation mark indicates that I<all> subroutines after it must 3031731Sjkhhave hints declared. 3041731Sjkh 3053647Sphk # foo() and bar() must have their hints defined 3061285Srgrimes use autodie qw( !foo !bar baz ); 3073764Sphk 3082570Srgrimes # Everything must have hints (recommended). 3093764Sphk use autodie qw( ! foo bar baz ); 3102779Srgrimes 3111285Srgrimes # bar() and baz() must have their hints defined 3122779Srgrimes use autodie qw( foo ! bar baz ); 3132779Srgrimes 3141285Srgrimes # Enable autodie for all of Perl's supported built-ins, 3153764Sphk # as well as for foo(), bar() and baz(). Everything must 3162779Srgrimes # have hints. 3173764Sphk use autodie qw( ! :all foo bar baz ); 3183764Sphk 3191285SrgrimesIf hints are not available for the specified subroutines, this will cause a 3201205Srgrimescompile-time error. Insisting on hints for Perl's built-in functions 3213607Sphk(eg, C<open> and C<close>) is always successful. 3222779Srgrimes 3232779SrgrimesInsisting on hints is I<strongly> recommended. 324568Srgrimes 3251027Sache=cut 3261027Sache 3271731Sjkh# TODO: implement regular expression hints 328333Srgrimes 329284Srgrimesuse constant UNDEF_ONLY => sub { not defined $_[0] }; 330358Srgrimesuse constant EMPTY_OR_UNDEF => sub { 3312570Srgrimes ! @_ or 332284Srgrimes @_==1 && !defined $_[0] 3331194Srgrimes}; 3341243Srgrimes 3351194Srgrimesuse constant EMPTY_ONLY => sub { @_ == 0 }; 3361194Srgrimesuse constant EMPTY_OR_FALSE => sub { 3373647Sphk ! @_ or 3383647Sphk @_==1 && !$_[0] 3391731Sjkh}; 3401731Sjkh 3413647Sphkuse constant SINGLE_TRUE => sub { @_ == 1 and not $_[0] }; 3421731Sjkh 3431762Sjkhuse constant DEFAULT_HINTS => { 344284Srgrimes scalar => UNDEF_ONLY, 3451194Srgrimes list => EMPTY_OR_UNDEF, 3461194Srgrimes}; 3471194Srgrimes 3481194Srgrimes 349358Srgrimesuse constant HINTS_PROVIDER => 'autodie::hints::provider'; 3501194Srgrimes 351358Srgrimesour $DEBUG = 0; 352358Srgrimes 3531243Srgrimes# Only ( undef ) is a strange but possible situation for very 354333Srgrimes# badly written code. It's not supported yet. 355284Srgrimes 3562779Srgrimesmy %Hints = ( 3572779Srgrimes 'File::Copy::copy' => { scalar => SINGLE_TRUE, list => SINGLE_TRUE }, 3581027Sache 'File::Copy::move' => { scalar => SINGLE_TRUE, list => SINGLE_TRUE }, 3591205Srgrimes 'File::Copy::cp' => { scalar => SINGLE_TRUE, list => SINGLE_TRUE }, 3602779Srgrimes 'File::Copy::mv' => { scalar => SINGLE_TRUE, list => SINGLE_TRUE }, 3611205Srgrimes); 3621782Sjkh 363284Srgrimes# Start by using Sub::Identify if it exists on this system. 3641205Srgrimes 3653607Sphkeval { require Sub::Identify; Sub::Identify->import('get_code_info'); }; 3662779Srgrimes 3672779Srgrimes# If it doesn't exist, we'll define our own. This code is directly 368568Srgrimes# taken from Rafael Garcia's Sub::Identify 0.04, used under the same 3691027Sache# license as Perl itself. 3701027Sache 3711731Sjkhif ($@) { 372333Srgrimes require B; 373284Srgrimes 374358Srgrimes no warnings 'once'; 3752779Srgrimes 3762779Srgrimes *get_code_info = sub ($) { 3771769Sjkh 3781769Sjkh my ($coderef) = @_; 3792779Srgrimes ref $coderef or return; 3802779Srgrimes my $cv = B::svref_2object($coderef); 3811769Sjkh $cv->isa('B::CV') or return; 3821769Sjkh # bail out if GV is undefined 3831769Sjkh $cv->GV->isa('B::SPECIAL') and return; 384284Srgrimes 385444Srgrimes return ($cv->GV->STASH->NAME, $cv->GV->NAME); 3861194Srgrimes }; 3871194Srgrimes 3882779Srgrimes} 3891769Sjkh 3901731Sjkhsub sub_fullname { 3911731Sjkh return join( '::', get_code_info( $_[1] ) ); 3921731Sjkh} 3931731Sjkh 3941731Sjkhmy %Hints_loaded = (); 3951731Sjkh 396284Srgrimessub load_hints { 3972779Srgrimes my ($class, $sub) = @_; 3982779Srgrimes 3991027Sache my ($package) = ( $sub =~ /(.*)::/ ); 4001205Srgrimes 4012779Srgrimes if (not defined $package) { 4021205Srgrimes require Carp; 4031782Sjkh Carp::croak( 404284Srgrimes "Internal error in autodie::hints::load_hints - no package found. 405372Srgrimes "); 406372Srgrimes } 407538Srgrimes 4081782Sjkh # Do nothing if we've already tried to load hints for 409372Srgrimes # this package. 4101782Sjkh return if $Hints_loaded{$package}++; 4112570Srgrimes 4121782Sjkh my $hints_available = 0; 4132570Srgrimes 4141782Sjkh { 4151782Sjkh no strict 'refs'; ## no critic 4161782Sjkh 417538Srgrimes if ($package->can('DOES') and $package->DOES(HINTS_PROVIDER) ) { 418376Srgrimes $hints_available = 1; 4191782Sjkh } 4201782Sjkh elsif ( PERL58 and $package->isa(HINTS_PROVIDER) ) { 421376Srgrimes $hints_available = 1; 422538Srgrimes } 423376Srgrimes elsif ( ${"${package}::DOES"}{HINTS_PROVIDER.""} ) { 4241782Sjkh $hints_available = 1; 4252570Srgrimes } 426376Srgrimes } 427538Srgrimes 428538Srgrimes return if not $hints_available; 4291782Sjkh 4301782Sjkh my %package_hints = %{ $package->AUTODIE_HINTS }; 431538Srgrimes 432538Srgrimes foreach my $sub (keys %package_hints) { 433538Srgrimes 4341782Sjkh my $hint = $package_hints{$sub}; 4351782Sjkh 436538Srgrimes # Ensure we have a package name. 437538Srgrimes $sub = "${package}::$sub" if $sub !~ /::/; 438538Srgrimes 4391782Sjkh # TODO - Currently we don't check for conflicts, should we? 4401782Sjkh $Hints{$sub} = $hint; 441538Srgrimes 442538Srgrimes $class->normalise_hints(\%Hints, $sub); 443538Srgrimes } 4441782Sjkh 4451782Sjkh return; 446538Srgrimes 447538Srgrimes} 448538Srgrimes 4491782Sjkhsub normalise_hints { 4501782Sjkh my ($class, $hints, $sub) = @_; 4511782Sjkh 452538Srgrimes if ( exists $hints->{$sub}->{fail} ) { 453538Srgrimes 454538Srgrimes if ( exists $hints->{$sub}->{scalar} or 4551782Sjkh exists $hints->{$sub}->{list} 4561782Sjkh ) { 457538Srgrimes # TODO: Turn into a proper diagnostic. 458538Srgrimes require Carp; 459538Srgrimes local $Carp::CarpLevel = 1; 4601782Sjkh Carp::croak("fail hints cannot be provided with either scalar or list hints for $sub"); 4611782Sjkh } 462538Srgrimes 463538Srgrimes # Set our scalar and list hints. 464538Srgrimes 4651782Sjkh $hints->{$sub}->{scalar} = 4661782Sjkh $hints->{$sub}->{list} = delete $hints->{$sub}->{fail}; 467538Srgrimes 468538Srgrimes return; 469538Srgrimes 4701782Sjkh } 4711782Sjkh 472538Srgrimes # Check to make sure all our hints exist. 473538Srgrimes 474538Srgrimes foreach my $hint (qw(scalar list)) { 4751782Sjkh if ( not exists $hints->{$sub}->{$hint} ) { 4761782Sjkh # TODO: Turn into a proper diagnostic. 477538Srgrimes require Carp; 478538Srgrimes local $Carp::CarpLevel = 1; 479538Srgrimes Carp::croak("$hint hint missing for $sub"); 4801782Sjkh } 4811782Sjkh } 482538Srgrimes 483538Srgrimes return; 484538Srgrimes} 4851782Sjkh 4861782Sjkhsub get_hints_for { 487538Srgrimes my ($class, $sub) = @_; 4882619Srgrimes 4891782Sjkh my $subname = $class->sub_fullname( $sub ); 4901782Sjkh 4911782Sjkh # If we have hints loaded for a sub, then return them. 492538Srgrimes 493372Srgrimes if ( exists $Hints{ $subname } ) { 494372Srgrimes return $Hints{ $subname }; 495372Srgrimes } 496372Srgrimes 497372Srgrimes # If not, we try to load them... 498372Srgrimes 499372Srgrimes $class->load_hints( $subname ); 500372Srgrimes 501372Srgrimes # ...and try again! 502372Srgrimes 503372Srgrimes if ( exists $Hints{ $subname } ) { 504372Srgrimes return $Hints{ $subname }; 505372Srgrimes } 506372Srgrimes 507372Srgrimes # It's the caller's responsibility to use defaults if desired. 508372Srgrimes # This allows on autodie to insist on hints if needed. 509372Srgrimes 510372Srgrimes return; 511372Srgrimes 512372Srgrimes} 513372Srgrimes 514372Srgrimessub set_hints_for { 515372Srgrimes my ($class, $sub, $hints) = @_; 516372Srgrimes 517372Srgrimes if (ref $sub) { 518372Srgrimes $sub = $class->sub_fullname( $sub ); 519372Srgrimes 520538Srgrimes require Carp; 5211782Sjkh 522372Srgrimes $sub or Carp::croak("Attempts to set_hints_for unidentifiable subroutine"); 523372Srgrimes } 524147Srgrimes 5252779Srgrimes if ($DEBUG) { 5262779Srgrimes warn "autodie::hints: Setting $sub to hints: $hints\n"; 5272779Srgrimes } 5282779Srgrimes 5293018Srgrimes $Hints{ $sub } = $hints; 5303018Srgrimes 5313018Srgrimes $class->normalise_hints(\%Hints, $sub); 5323654Sphk 5333654Sphk return; 5343654Sphk} 5353018Srgrimes 5363654Sphk1; 537372Srgrimes 538410Srgrimes__END__ 539147Srgrimes 5403764Sphk 541372Srgrimes=head1 Diagnostics 5421731Sjkh 5431769Sjkh=over 4 5441731Sjkh 545372Srgrimes=item Attempts to set_hints_for unidentifiable subroutine 5462779Srgrimes 5472611SrgrimesYou've called C<< autodie::hints->set_hints_for() >> using a subroutine 5483654Sphkreference, but that reference could not be resolved back to a 549372Srgrimessubroutine name. It may be an anonymous subroutine (which can't 55037Srgrimesbe made autodying), or may lack a name for other reasons. 551 552If you receive this error with a subroutine that has a real name, 553then you may have found a bug in autodie. See L<autodie/BUGS> 554for how to report this. 555 556=item fail hints cannot be provided with either scalar or list hints for %s 557 558When defining hints, you can either supply both C<list> and 559C<scalar> keywords, I<or> you can provide a single C<fail> keyword. 560You can't mix and match them. 561 562=item %s hint missing for %s 563 564You've provided either a C<scalar> hint without supplying 565a C<list> hint, or vice-versa. You I<must> supply both C<scalar> 566and C<list> hints, I<or> a single C<fail> hint. 567 568=back 569 570=head1 ACKNOWLEDGEMENTS 571 572=over 573 574=item * 575 576Dr Damian Conway for suggesting the hinting interface and providing the 577example usage. 578 579=item * 580 581Jacinta Richardson for translating much of my ideas into this 582documentation. 583 584=back 585 586=head1 AUTHOR 587 588Copyright 2009, Paul Fenwick E<lt>pjf@perltraining.com.auE<gt> 589 590=head1 LICENSE 591 592This module is free software. You may distribute it under the 593same terms as Perl itself. 594 595=head1 SEE ALSO 596 597L<autodie>, L<Class::DOES> 598 599=for Pod::Coverage get_hints_for load_hints normalise_hints sub_fullname get_code_info 600 601=cut 602