Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

warnings for modules < 5.6

by liz (Monsignor)
on Jul 29, 2003 at 12:09 UTC ( [id://278796]=CUFP: print w/replies, xml ) Need Help??

Since it seems there is not going to be a quick solution to the problem of modules running under perl < 5.6 with "use warnings" (see 278753), I thought I'd add this piece of code to the snippets. Courtesy of Podmaster. Documentation added for those monks not really familliar with BEGIN, GLOBs and %INC.

Liz

# Do this at compile time BEGIN { # Check if there is a warnings module available eval { require warnings; # If not, create dummy "import" and "unimport" subroutines } or do { no strict 'refs'; *warnings::import = *warnings::unimport = sub{}; # Make sure no attempt will be made to load the "warnings.pm" file ev +er again $INC{'warnings.pm'} = ''; } } #BEGIN

Replies are listed 'Best First'.
Re: warnings for modules < 5.6
by Jenda (Abbot) on Aug 13, 2003 at 12:32 UTC

    The fake import() and unimport() is not necessary actually.

    Jenda
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
       -- Rick Osborne

    Edit by castaway: Closed small tag in signature

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2024-03-19 06:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found