use warnings; #use strict; my @toks; while(<>){ if(/(\S+)\s+ASH\s+CLOUD/oi){ push @toks, [ 'ASH CLOUD', $1 ]; } map { if(/([NSEW]\d+)/){ push @toks, [ 'COORD', $1 ]; } } split(/\s+/, $_); } my $print_coords = 0; my (@lat,@lon); map { if($_->[0] eq 'ASH CLOUD'){ if($_->[1] eq 'OBS'){ $print_coords = 1; } else { $print_coords = 0; } } if($_->[0] eq 'COORD' and $print_coords){ $bar=substr ($_->[1],0,1); if($bar eq "S" || $bar eq "W"){ $foo=substr ($_->[1],1,5); $foo=-$foo/100; push @lat $foo; } else { $foo=substr ($_->[1],1,5); $foo=$foo/100; push @lon $foo; } } } @toks; exit 0;