Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^2: Find duplicate elements from an array

by mjscott2702 (Pilgrim)
on Nov 22, 2010 at 08:52 UTC ( #872929=note: print w/replies, xml ) Need Help??

in reply to Re: Find duplicate elements from an array
in thread Find duplicate elements from an array

Yep, HoA is what you need, keyed by name, simply unshift (if you want the second page number before the first - you specify this, but the example doesn't back it up) the page number onto the beginning of the 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


$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
    Thank you so much.. mjscott2702

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://872929]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2017-11-24 15:32 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (349 votes). Check out past polls.