in reply to Reading file into an array and working with it.

Sounds like to need to look at perldoc perllol and perldoc perdsc, both of which cover this in some detail.

In summary you'd do something like this (assuming your delimiter is a tab):

my @data; open(DATA, $file) || die "Can't open $file: $!\n"; while (<DATA>) { push @data, [split /\t/]; }

You would then access the various elements like this:

my $town = 'London'; my ($lat, $long); foreach (@data) { if $_->[0] eq $town; ($lat, $long) = ($_->[1], $_->[2]); last; }

However, if this is how you are going to be using the data, then you might be better off building a hash of arrays, where the key to the hash is the town name and the value is a two element list containing lat and long. You would construct that something like this:

my %data; open(DATA, $file) || die "Can't open $file: $!\n"; while (<DATA>) { my ($town, @vals) = split(/\t/); $data{$town} = \@vals; }

you could then get the lat and long for a particular town like this:

my ($lat, $long) = @{$data{$town}};

Hope this helps

--
<http://www.dave.org.uk>

European Perl Conference - Sept 22/24 2000
<http://www.yapc.org/Europe/>