At 07:34 2005-06-30, L. Neil Johnson wrote:
As mentioned previously, I got tired of editing the absolute indices (e.g.,
$trade[$i]->[6]) every time the order or meaning of an element of the anonymous
arrays changed; so in main I defined typeglobs:

This is what I meant when I said a hash is a good solution to this problem. You're not really interested in the order, you want to access each element by a convenient name.

It sounds like a bit of data to keep in memory, so going from an array to a hash may not be feasible because of that, but if it is it would look like this instead:

$trade[$i]->{"time_elapsed"}

If your available memory can take this hit, I'd consider that approach a lot more maintainable. If not, go with either exported constants or simply $UPPER_CASE_VARIABLES as named indices into the array.

And to me it looks like the solution would be more clear with each record being an object, but if you're not familiar with OO, don't start introducing it in this program. Try it out with something small and new.

http://www.manning.com/books/conway is excellent.


/J

-------- ------ ---- --- -- --  --  -     -     -        -          -
Johan Lindström    Sourcerer @ Boss Casinos   johanl AT DarSerMan.com

Latest bookmark: "TCP Connection Passing"
http://tcpcp.sourceforge.net/
dmoz: /Computers/Programming/Languages/JavaScript/ 12

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to