Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: no module warnings in client code

by citromatik (Curate)
on Aug 27, 2013 at 14:05 UTC ( #1051140=note: print w/replies, xml ) Need Help??


in reply to Re: no module warnings in client code
in thread no module warnings in client code

Hi kennethk

My suggested code doesn't work... If it had worked I wouldn't have asked!

Here is a testing code:

Package:

package tt; use strict; use warnings; sub w { my $str = ""; return substr ($str, 10, 10); } 1;

Client script:

use strict; use tt; print tt::w();

Defining a local warning handler works perfectly:

use strict; use tt; local $SIG{__WARN__} = sub {}; print tt::w();

Thanks for the help

citromatik

Replies are listed 'Best First'.
Re^3: no module warnings in client code
by 2teez (Vicar) on Aug 27, 2013 at 14:41 UTC
    Hi citromatik,
    And you might want to but local $SIG{__WARN__} = sub{}; into a block like kennethk did it.
    If not, you would not receive any other warnings from your client script.
    Just saying ...
    If you tell me, I'll forget.
    If you show me, I'll remember.
    if you involve me, I'll understand.
    --- Author unknown to me

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2020-05-29 07:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (167 votes). Check out past polls.

    Notices?