in reply to %hash (@array && use constant) in Modules
Perl hashes usually gets the job done with the least amount of effort. I use them where I'd use C structs, Java Objects, Vectors, Sets or whatever. They are extremely versatile beasts. It's only when I have ordered data that I have the need for arrays, really. Which leads me to the point I'm trying to make:
For most classes, the members aren't ordered among themselves. In your example, the foo and bar member variables have no real relation to each other and aren't ordered. Since they only exist to hold named pieces of data it makes perfect sense to me to store them in a hash. Of course, there are classes where it'd be more intuitive to use an array but I can't think of a good examle right now. And anyway, if I needed a class to store ordered data, I'd still use a hash and let one of the member variables be a reference to an anonymous array.
Cheers,
--Moodster
|
|---|