in reply to make a search pattern and remove duplicate from the file
I did not understand your specifications well enough to figure out how you came to get the output you want. but you can loop through this structure (or something close) to generate that.$ perl -MData::Dumper -lanF\\\| -e 'for (@F){@x=split /=/;$h{$x[0]} +=$x[1]};$pet_hate{$h{pet}}{HATE}{$h{hate}}++;$pet_hate{$h{pet}}{LIKE} +{$h{like}}++; }{print Dumper \%pet_hate' your-file.txt $VAR1 = { '"cow"' => { 'HATE' => { '"rat"' => 3 }, 'LIKE' => { '"dog"' => 3 } }, '"cat"' => { 'LIKE' => { '"horse"' => 1, '"dog"' => 2 }, 'HATE' => { '"rat"' => 3 } } };
Memory fault -- brain fried
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: make a search pattern and remove duplicate from the file
by jimpudar (Pilgrim) on May 11, 2018 at 16:15 UTC | |
by NetWallah (Canon) on May 11, 2018 at 20:15 UTC | |
by jimpudar (Pilgrim) on May 12, 2018 at 15:30 UTC |