in reply to Re: Find duplicate elements from an array
in thread Find duplicate elements from an array
use strict; use warnings; use Data::Dumper; my %HoA = (); while (<DATA>) { if (/(.+)\s+(\d+)\s*$/) { unshift(@{$HoA{$1}}, $2); } } print Dumper(\%HoA); __DATA__ Barmparas, Galinos, 1120 Barmparas, Galinos, 1410 Beal, Alan, 866 Beall, Dawson, 1062
Output:
$VAR1 = { 'Beal, Alan,' => [ '866' ], 'Beall, Dawson,' => [ '1062' ], 'Barmparas, Galinos,' => [ '1410', '1120' ] };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Find duplicate elements from an array
by tej (Scribe) on Nov 22, 2010 at 10:49 UTC |