Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Color die and warn messages

by dbuckhal (Chaplain)
on Mar 02, 2024 at 06:28 UTC ( [id://11158054]=note: print w/replies, xml ) Need Help??


in reply to Color die and warn messages

Hey, just silly thought I had regarding your "NOTE"

# NOTE: Doesn' play well with Carp::Always because it replaces our die

Since you are colorizing, instead of "die", use "dye" to prevent clobbering.

Otherwise, cool concept!

... I really hope Anonymous Monk gets this response ...

Replies are listed 'Best First'.
Re^2: Color die and warn messages
by Anonymous Monk on Sep 16, 2024 at 16:44 UTC
    Your quote is incomplete: "it replaces our die and warn sighandlers". The point of the code is to be drop-in and not require any other changes in your code. In fact, it would be better to call it in an eval so if it's not installed, it doesn't break anything: BEGIN { eval 'use warnings::colored' };.

    Changing die to dye would require you to change any code that uses it, and also it wouldn't then work on anything that internally called die or warn, like the example: system 'nonexistent-command'.

    If the %SIG entries could be tied variables, then it might be possible to make this play nice with Carp::Always. I haven't looked into that because it works fine enough as it is for me. That's why I released it anonymously and not to CPAN. If somebody wants to improve on it and deal with the edge cases, feel free to release it.

      In fact, it would be better to call it in an eval so if it's not installed, it doesn't break anything: BEGIN { eval 'use warnings::colored' };.
      Better yet, invoke it using an environment variable: PERL5OPT="-M5;BEGIN{eval{require warnings::colored)}}" as mentioned here: Re: Is it possible load optional modules from PERL5OPT?.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2026-04-11 21:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.