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 |