in reply to Objects as hash keys?
Looks like it can be done...package MyObj; sub new { bless {}, shift; } 1; --- #!/usr/bin/perl -w use MyObj; my %hash; my $a = MyObj->new(); my $b = MyObj->new(); $hash{$a} = "This is my Object A"; $hash{$b} = "This is my Object B"; print $a, "\n"; print $b, "\n"; print $_, " : ", $hash{$_}, "\n" foreach keys %hash; __END__ MyObj=HASH(0x2001b1fc) MyObj=HASH(0x2001b2e0) MyObj=HASH(0x2001b1fc) : This is my Object A MyObj=HASH(0x2001b2e0) : This is my Object B
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Objects as hash keys?
by ikegami (Patriarch) on May 17, 2005 at 16:59 UTC | |
by artist (Parson) on May 17, 2005 at 17:15 UTC |