Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Removing Duplicates from a multiline entry

by blue_cowdawg (Prior)
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 chilling in the Monastery: (16)
As of 2014-07-31 14:01 GMT
Find Nodes?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:

    Results (249 votes), past polls