Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: using modules with 'no warnings' in perl 5.005

by liz (Monsignor)
on Jul 29, 2003 at 08:08 UTC ( [id://278759]=note: print w/replies, xml ) Need Help??


in reply to using modules with 'no warnings' in perl 5.005

Creating a mock warnings.pm and putting it on CPAN, was actually discussed at the p5p BOF at YAPC::Europe. Unfortunately (and this is my opinion) it was deciced to not do this (yet) because of the uncertainty of all the ramifications, particularly involving version numbers (you don't want CPAN installing perl 5.8.0 because some module author added warnings.pm as a prerequisite, for instance).

However, you can mock it like this:

BEGIN { unless (eval "require warnings;") { eval <<EOD; sub warnings::import {}; sub warnings::unimport {}; EOD $INC{'warnings.pm'} = 'I do not really exist'; } } #BEGIN

Liz

Replies are listed 'Best First'.
Re: Re: using modules with 'no warnings' in perl 5.005
by PodMaster (Abbot) on Jul 29, 2003 at 08:20 UTC
    Everybody is too eval(string) happy for my tastes ;)
    BEGIN { eval { require warnings; 1 } or do { no strict 'refs'; *warnings::import = *warnings::unimport = sub{}; $INC{'warnings.pm'}=''; }; }

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      Ok, fair enough.

      One question though: the 1 in line 4 of your code seems superfluous to me. A successful 'require warnings' should return a true value anyway, no?

      Liz
        Yup, it's just a force of habit, like including a "1;" at the "official" end of every package within a single file.

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (9)
As of 2024-04-23 11:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found