in reply to Array of Hash interface to an Array of Array?

The popular technique seems to be
use constant name => 0; use constant age => 1; use constant height => 2; my $people = [ [ 'fred', 25, 1.5 ], [ 'sally', 20, 1.4 ], ]; for my $person( @$people ) { print $person->[name],"\n"; } __END__
POE uses it.

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re: Re: Array of Hash interface to an Array of Array?
by jaa (Friar) on Sep 01, 2003 at 14:52 UTC

    I like 2POE too!

    Unfortunately consts dont quite hit the spot in this case - for example I have several arrays, with 'name' columns at different offsets, and the AofH and H's get passed around a number of modules, so there are scoping issues.

    I was wondering more about some sort of class that I could overlay on an AoA to make the thingies pretend they were Hashes even though there would only be one hash mapping the names to an array offset...

    Maybe there is a clue in Abigail's posting... off to google pseudo-hash...

    Regards

    Jeff