#!/usr/bin/perl use strict; use warnings; use diagnostics; # Fake up a couple of data files my %dataFiles = ( data1 => < <)) { chomp $filename; next if !length $filename; push @coords, "Path: $filename\n"; #opens the actual file that will be processed open my $inData, '<', \$dataFiles{$filename} or die "(L2)We've got a problem: $!"; while (defined (my $line = <$inData>)) { next if $line !~ /\s+(-?\d+\.\d+)\s+(-?\d+\.\d+)/; #Append the coordinates (with the '-' sign where appropriate) push (@coords, "$1 || $2 \n"); } close ($inData); } close ($inFile); print @coords;