in reply to Count the Duplicate Entries and make them uniq
Here's another option:
use Modern::Perl; my %hash; map { /(.+)?,(.+)/; $hash{$1}{$2}++ } <DATA>; say 'OS,RELEASE,Yes,No'; say "$_," . ( $hash{$_}{Yes} || 0 ) . ',' . ( $hash{$_}{No} || 0 ) for sort keys %hash; __DATA__ Ubuntu,Warty,No Ubuntu,Hoary,No Ubuntu,Breezy,Yes Ubuntu,Breezy,Yes Fedora,Yarrow,Yes Fedora,Stentz,No Fedora,Yarrow,Yes Fedora,Yarrow,Yes Windows,XP PRO,Yes Windows,XP PRO,Yes Windows,XP Home,No Windows,XP PRO,Yes
Output:
OS,RELEASE,Yes,No Fedora,Stentz,0,1 Fedora,Yarrow,3,0 Ubuntu,Breezy,2,0 Ubuntu,Hoary,0,1 Ubuntu,Warty,0,1 Windows,XP Home,0,1 Windows,XP PRO,3,0
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Count the Duplicate Entries and make them uniq
by slayedbylucifer (Scribe) on Aug 30, 2012 at 04:22 UTC | |
by slayedbylucifer (Scribe) on Aug 30, 2012 at 04:24 UTC | |
by Kenosis (Priest) on Aug 30, 2012 at 04:36 UTC |