Next | Making Programs Faster | 88 |
Hashes are commonly used for objects
Keys are member data names, values are member data
if ($self->{TYPE} eq 'octopus') { $self->{tentacles} = 8; $self->{hearts} = 3; $self->{favorite_food} = 'crab cakes'; }
But arrays are smaller and faster
Big disadvantage: Data is referred to by number instead of by name
if ($self->[2] eq 'octopus') { $self->[17] = 8; $self->[4] = 3; $self->[28] = 'crab cakes'; }
Next | Copyright © 2003 M. J. Dominus |