[Israel.pm] use constant

Amir E. Aharoni amir.aharoni at gmail.com
Sun Mar 2 12:50:42 EET 2008


On 02/03/2008, ik <idokan at gmail.com> wrote:
>  I keep on seeing people using regular "my" or "our" for data that
>  should not be changed. Why most Perl developers does not use the "use
>  constant" way instead ?

Damian Conway suggests not to 'use constant' in the book "Perl Best
Practices" and i totally agree with him about this. It is annoying -
it doesn't look like a variable and it cannot be interpolated.

He suggests a couple of other solutions, such as 'use Readonly', but
unfortunately it is not a part of standard Perl library.

I avoid 'use constant' unless i have a reason to use it  (such as
consistency with legacy code). I just use 'my' most of the time. It's
not such a big deal and there are worse problems with Perl than the
ability to change values of constants.

-- 
Amir Elisha Aharoni

English -  http://aharoni.wordpress.com
Hebrew  - http://haharoni.wordpress.com

"We're living in pieces,
 I want to live in peace." - T. Moore


More information about the Perl mailing list