in reply to How can I read multiple lines starting with the same number and put in to a nested array and print it to a file?

My mind tumbled through several permutations in reading your post, so I hope one of them will prove helpful or illuminative.

When I first looked at this, the thought of "homework" passed briefly through my mind, but with just the ideas I am tossing out, it would still be up to you how best to implement the information, so I don't think that will be a factor herein.

My first thought about the question regarding how to put it into a data structure was that perhaps you were looking at something reminiscent of a radix sort. There are several references for such things online, easily found through a search such as Google, so I'll forego that as well.

One thing you may wish to look at is using a hash of arrays, so you might have something like $yourhash{'5'}(0..5) = ('567888871', '567888871', '567888871', '567888871', '546666624', '534889032'), for instance. You might wish to check my syntax, as I am writing this without a terminal window open to test it in, but you get the idea.

Another option might be an array of arrays, so that in the above you end up with $yourarray[5][4] = '546666624'.

You may wish to review perllol or another such reference for additional assistance.

I look forward to others' responses, so I may learn as well.

  • Comment on Re: How can I read multiple lines starting with the same number and put in to a nested array and print it to a file?