Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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

Comment on Re: Removing Duplicates from a multiline entry
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2015-10-09 14:30 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (242 votes), past polls