Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (14)
As of 2015-07-29 14:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls