|
From: Wizard <wi...@ne...> - 2002-01-29 00:37:00
|
> Would the "use constant CONSTANTNAME => VALUE" be more efficient? As
> efficient as scalars, arrays or hash?
No, all that 'use constant X' does is create an anonymous subroutine 'X'.
It's equivalent to:
*X = sub () { <value> };
which is basically what you are suggesting. 'use constant' also isn't
supported in 5.004x, which I believe is the target.
> Maybe I'm pushing it too far, but I thought the aim of this project was
> to provide better quality (in delivering a service, in security and as
> a coding model) In my opinion, allowing what should be constants to be
> modified isn't a very secure practice. Would you do the same in C?
Provided that the code is written well, it shouldn't be possible to modify
ANY variables that aren't exposed through CGI (and I should hope that only
the ones that are necessary are).
The idea that Perl doesn't really have any constants is an ongoing debate
(and the reason for the 'use constants' hack). I personally believe that
Perl manages just fine without them, and provided the developer uses due
caution in the code, it really is only a issue of resources. As far as C
goes, It's an entirely different language, and not really a practical
comparison (Perl say's "What's a macro?") ;-)
Grant M.
|