On Mon, 22 Jan 2001 [EMAIL PROTECTED] wrote:
> (section 4.3, pp 126-135) I hadn't heard about pseudo-hashes. I now
> desire a data structure with non-numeric keys, definable iteration
> order, no autovivification, and happy syntax. (And, of course,
> fast-n-small :-) Having Conway's blessing is nice
Pseudo-hashes do not have Conway's blessing. We hired him to do a
tutorial for our engineers a few omnths back, and he railed about how
disappointing pseudo-hashes turned out to be and why no one should ever
use them. I had already reached the same conclusion after I saw that
everyone would have to remember to say "my Dog $spot;" every time or the
whole thing falls apart.
If you want something reasonably close, you could do what a lot of the
Template Toolkit code does and use arrays with constants for key
names. Here's an example:
package Dog;
use constant NAME => 1;
use constant ID => 2;
sub new {
my $self = [];
$self->[ NAME ] = 'spot';
$self->[ ID ] = 7;
return bless $self;
}
Or something like that, and make accessors for the member data. I think
there are CPAN modules which can automate this for you if you wish.
- Perrin