in reply to Deleting repeating array elements

I wonder if this is what you are aiming to do.

use strict; use warnings; use Data::Dumper; my %continents; while ( <DATA> ) { chomp; my( $continent, $country ) = split m{:}; push @{ $continents{ $continent } }, $country; } print Data::Dumper->Dumpxs( [ \ %continents ], [ qw{ *continents } ] ); __DATA__ Europe:Germany Europe:France Asia:India Europe:Italy Asia:Japan Asia:Indonesia

The output.

%continents = ( 'Europe' => [ 'Germany', 'France', 'Italy' ], 'Asia' => [ 'India', 'Japan', 'Indonesia' ] );

I hope I have guessed correctly and this is of some help.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^2: Deleting repeating array elements
by biohisham (Priest) on Aug 17, 2009 at 23:46 UTC
    This is exactly the sort of code steps that I got in my mind, I remember having read a similar solution at some tutorials but I could not retrieve it today that I needed it, what a shame. Thanks a lot, I appreciate this :)


    Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.