Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: What is the difference between the constant construct in Perl and the Readonly construct in Perl?

by tfrayner (Curate)
on Jul 06, 2006 at 09:36 UTC ( #559528=note: print w/replies, xml ) Need Help??


in reply to What is the difference between the constant construct in Perl and the Readonly construct in Perl?

Hi,

A key feature (in my view) of Readonly that others haven't mentioned yet is that a Readonly hashref will prevent you from modifying the referenced hash. The constant pragma, in contrast, only prevents you from changing the top-level reference value. The constant will always point to the same hash, but that hash can be modified. Maybe this might change in future, I don't know, but in the meantime I've been bitten by this not-entirely-constant nature of the constant pragma (inadvertently using a "constant" hash as a global variable...). It's fine for scalar and array values, but a bit dodgy for hashes, IMHO.

cheers,
Tim

  • Comment on Re: What is the difference between the constant construct in Perl and the Readonly construct in Perl?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://559528]
help
Chatterbox?
[corenth]: i have a question. I used map{ blah();blah(); blah();}@stuff; and it used up a ton of memory vs. the for(@stuff){} equivalent. What gives? (if anyone knows)
[Cosmic37]: FANN also has LGPL license which I like and its supposed to be quite a capable library from what I read
[corenth]: Cosmic, that sounds interesting. What is FANN (I could search it if I weren't so lazy about it)?
[Cosmic37]: how big was @stuff corenth?
[Cosmic37]: Fast Artificial Neural Network (FANN) is cross-platform open source programming library for developing multilayer feedforward Artificial Neural Networks
[corenth]: @stuff was pretty big. I think it grew to about 8000.
[corenth]: each element was several three + element references

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2018-02-20 18:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (274 votes). Check out past polls.

    Notices?