----- Original Message -----
From: "Paul Johnson" <p...@pjcj.net>
To: "Stanisław T. Findeisen" <sf181...@students.mimuw.edu.pl>
Cc: beginners@perl.org
Sent: Thursday, 12 March, 2009 19:27:02 GMT -07:00 US/Canada Mountain
Subject: Re: use constant

On Thu, Mar 12, 2009 at 11:50:46PM +0100, "Stanisław T. Findeisen" wrote:

> Is there any way to change the values of [scalar/array] constants  
> defined via "use constant" pragma?

That seems a strange thing to want to do.  But useful for redefining pi, or
perhaps G, I suppose.

In general the answer is no.  But if you can live with a mandatory warning and
the knowledge that you have lied to perl (and you understand the effects that
brings, specifically with respect to constant propagation) then go ahead and
do it.

It's not a good idea, but it's not in perl's nature to pretend that she knows
better than you, even if she does.

If you want a constant that varies, can you not just use a variable?

-- 
Paul Johnson - p...@pjcj.net
http://www.pjcj.net

--

I do this regularly redefine constants in my programs. I'm not sure if it's 
good practice but I do it.

What I do is define a constant in most subroutines. The constant is called, 
strange enough, PROC_NM. I felt that because this was being defined local to 
each routine that I wasn't breaking all the rules I had been taught. I know I 
get a warning message each time I redefine it but to me it is a local constant 
not a variable. I don't define it in my helper routines so when they printout 
an error message and reference PROC_NM I know where they are called from.

If anyone has a better idea I'd love to hear it.


Suzanne. 
--------- 
Suzanne Aardema 
Systems Analyst/Programmer 
Applications Development 
Computing Services 
Athabasca University 
1 University Drive 
Athabasca, AB T9S 3A3 

ph: 780-421-2527 
fax: 780-428-2464 
email: suzan...@athabascau.ca 

__ 
    This communication is intended for the use of the recipient to whom it
    is addressed, and may contain confidential, personal, and or privileged
    information. Please contact us immediately if you are not the intended
    recipient of this communication, and do not copy, distribute, or take
    action relying on it. Any communications received in error, or
    subsequent reply, should be deleted or destroyed.
---

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to