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

Re: Removing Duplicates from a multiline entry

by blue_cowdawg (Monsignor)
on Feb 27, 2013 at 13:51 UTC ( #1020891=note: print w/replies, xml ) Need Help??

in reply to Removing Duplicates from a multiline entry

So... what have you tried? The algorithm is fairly simple:

pseudo code: master_hash <- empty hash while more lines readline line contains /^Product\s+(\d+)/? temp_hash <- empty_hash index_key <- $1 #see capture above while in product record do read line throw away if contains /^[\-]+$/ if contains /=/ split line on '=' key <- field 0 value <- field 1 temp_hash[key] <- value end if done if line blank next if master_hash has $index_key master_hash[index_key] <- temp_hash done if last line
Now, I've given you enough to chew on and come up with your own code without writing it for you. I await your try/fail attempts. :-)

Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1020891]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2018-04-20 17:02 GMT
Find Nodes?
    Voting Booth?