Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Iterating through an array using multiple loops and removing array elements

by Laurent_R (Canon)
on Apr 24, 2014 at 06:42 UTC ( [id://1083533]=note: print w/replies, xml ) Need Help??


in reply to Iterating through an array using multiple loops and removing array elements

If I understood you correctly, you don't need nested loops to do what you want. And you also don't need to store your file in an array in the first place. You can just read your input file, store the data from your first line in an array or a hash; then you go to the next line, if it meets the criteria of what you have already stored, add to the existing hash entry, otherwise create a new hash entry, and so on. In other word, you need only one pass through your file to get all what you need into the hash. At the end, print the hash content or do whatever you need with it.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-03-28 20:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found