Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: Constant redefined

by davido (Cardinal)
on May 31, 2005 at 01:20 UTC ( [id://461928]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re^2: Constant redefined
in thread Constant redefined

I'm sorry for misunderstanding the intent of your question. Ok, so despite the fact that it violates the intent of constants, you're looking for a way to suppress any error message anytime a constant is defined again with the "use constant..." directive. Here's some rope:

use warnings; use strict; BEGIN{ open OLDERR, '>&', \*STDERR or die "Couldn't save STDERR\n$!"; close STDERR; } INIT{ open STDERR, '>&', \*OLDERR or die "Couldn't retrieve STDERR\n$!"; } use constant PI => 3.14; use constant PI => 1000; print PI, "\n";

You are now suppressing any error messages that would occur during the stage of compilation where 'use' directives are being sorted out and compiled. That means there are a lot of other errors you won't see. In fact, I doubt you would even see any error caught by my 'or die...' clauses while saving away STDERR. I did give STDERR back to you for runtime stuff though. But this whole thing seems like a BAD IDEA.

By the way, holli is wrong about being able to wrap it in an eval BLOCK. I tried that too. ;)


Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://461928]
help
Sections?
Information?
Find Nodes?
Leftovers?
    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.