Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Testers needed: autodie 1.10 beta released - It's Fatal 2.0!

by pjf (Curate)
on Jun 24, 2008 at 13:45 UTC ( [id://693738]=note: print w/replies, xml ) Need Help??


in reply to Re: Testers needed: autodie 1.10 beta released - It's Fatal 2.0!
in thread Testers needed: autodie 1.10 beta released - It's Fatal 2.0!

Aha! My guess is this is going to be an @INC problem. autodie provides a heavily modified but backwards compatible Fatal.pm, which will be installed into your site_perl.

If you're using a version of Perl where site_perl is checked before your core modules, autodie should work fine. If not (and most distros are not), then autodie will try and load the core Fatal, and fail.

I've added detecting and fixing this to my TODO list. In the meantime, you should be able to tell Perl to search your site_perl first. The following should work on any unix-like system:

export PERL5LIB=`perldoc -l autodie | perl -pe's{[^/]*$}{};'`

Alternatively, you can use a more traditional use lib to ensure Perl looks in your appropriate site_lib first.

Many thanks,

Replies are listed 'Best First'.
Re^3: Testers needed: autodie 1.10 beta released - It's Fatal 2.0!
by pht (Acolyte) on Jul 05, 2008 at 20:09 UTC
    Thanks, that fixed it. One more question: autodie does not catch print failures, does it?

      The most recent autodie distributions on the CPAN should overwhelm your default Fatal.pm upon installation, avoiding any requirement to do odd things with @INC. Do this with caution on a production machine, because while I've taken extreme care to ensure full backwards compatibility with the old Fatal, if things break you'll be keeping both pieces.

      As for catching errors from print, unfortunately this isn't supported. At least, not yet. The autodie pragma generates replacements for the core built-ins, and in order to do this it needs to be able to divine their prototypes. Unfortunately, not all of Perl's built-ins have prototypes, the most notable exceptions being system and print.

      In the case of system, the exotic form of system { $cmd } @args is so rarely seen that autodie considers it to be an acceptable casualty if you use autodie qw(system), especially since the exotic form is only disabled until the end of the lexical scope where autodie was used.

      print, on the other hand, is regularly seen in the form print FILE $data or print {$fh} $data. Since the indirect argument prevents it having a clean prototype, I'd have to break these forms (although only with lexical scope), in order to have an autodying print.

      That's not something autodie supports yet, although given that I'd love to have print throw exceptions on error, that will probably change. However anyone wanting to use autodying print would need to ask for it explicitly (it won't be a default behaviour), and be aware that calls to CORE::print (or some other path) will be required if printing to an alternate filehandle is desired (and these won't be autodying).

      All the best,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://693738]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-03-28 12:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found