in reply to arrays or hashes

How about a hash of arrays!

eg. $hash{amsterdam} = [23, 88]; etc.

You can generate that from your file using:

#! perl -w use strict; my %data; # Choose a better name #open DATA, '<yourfile' or die "Couldn't open $DATA; $!"; while(<DATA>) { chomp; my ($place,$number) = split /\s+/; push @{$data{$place}}, $number; } #close DATA or warn "Couldn't close $DATA: $!"; for my $place (keys %data) { print $place, "\thas values: ("; print @{$data{$place}}[$_], ',' for (0 .. $#{$data{$place}}); print ")\n"; } __DATA__ amsterdam 23 amsterdam 88 london 65 ny 10 ny 16 la 21 la 65 miami 9 lapaz 10

The program produces this output.

C:\test>193169 miami has values: (9,) lapaz has values: (10,) ny has values: (10,16,) la has values: (21,65,) london has values: (65,) amsterdam has values: (23,88,) C:\test>

I'll leave cleaning the output up to you:^)


What's this about a "crooked mitre"? I'm good at woodwork!