Date: Wed, 11 Jul 2001 10:44:31 -0500 From: Michael Carman Subject: Re: Data structures question. Message-Id: <3B4C745F.5B55851A@home.com> Garry wrote: > > Michael Carman wrote in message > news:<3B4B28B3.61950B7C@home.com>... > > > I'd suggest using a LoH (list of hashes). Something like this: > > [snip example] > > Now *that* looks fantastic - thanks! I'd looked at hashes, but > couldn't find any examples that were close enough for me to see how to > apply them. There's enough info here for me to get to grips with it > now. You're welcome. Perl makes it easy to create complex data structures, and having your data in the right format makes it much easier to work with. After a while, you'll find yourself thinking much more about *what* you want to do, and a lot less time getting bogged down in the details of *how*. > Oh, one point for clarification ... the line > foreach my $n (0 .. $#connection) { > ... does that work along similar lines as ... > for ($n = 0; $n <= $#connection; $n++) { They're equivilant. The first is easier to write and more Perlish. Using the second one is like waving a big flag that says "I'm used to programming in C!" There's nothing wrong with that, per se, but in Perl it's rarely necessary to know what your loop index is, and as such it's rarely used (by experienced Perl hackers, anyway). I only used it in my example because in this case I wanted to print out the index. Otherwise I would have written it this way: foreach my $link (@connection) { foreach my $k (sort keys %$link) { print "\t$k - $link->{$k}\n"; } } -mjc