Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Array indices

by Zaxo (Archbishop)
on Sep 14, 2002 at 06:05 UTC ( [id://197809]=note: print w/replies, xml ) Need Help??


in reply to Array indices

There is nothing wrong with your logic. It is worthwhile, however, to try to make associated data stick together, and avoid data structures which must be maintained in parallel. I would try to make that data an AoH where the array maintains order, and the hash provides data that is clearly associated:

my @fullnames = ( {first => 'John', last => 'Brown'} #... };

The merits of zero based arrays come from C practice, where an array is synonymous with a pointer to its first element. Adding n element sizes gives the address of the n'th element.

In Perl, it is best to treat arrays as 'things' and avoid representation dependent methods, but indices are available if you need them.

For question 2, It depends on your data structure. I'd expect grep to play a part.

After Compline,
Zaxo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://197809]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-24 01:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found