Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quick error question...

Status
Not open for further replies.

Maldini

Technical User
Nov 10, 2002
55
GB
Hi,

Is there any way to disable the standard error messages that perl generates whilst not disablling the entire standard error channel?
Since I'm trying to produce my own error messages to be displayed and don't want the standard ones from perl to be shown.

Thx
 
I'm not sure what you mean by 'disable' the standard error messages. You can catch warn() and die() signals using
Code:
BEGIN {

    $SIG{__WARN__} = sub { 
                          # Throw your own warning here
                          # Maybe print @_
                      };
    $SIG{__DIE__} = sub {
                          # Dig your own grave and die gracefully
                          # Can do something with @_ here too
                          exit; 
                      };
}
jaa
 
ummm... well, say I'm using the getopts module..

I want the script not to display the standard error message...
like script -a
where a is not an option, I don't want the "Unknown Option: a" line, rather I want to send my own error message onto standard error.

Does the method you detailed above do that?
Thx again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top