#!/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; #### Path: data1 5194.5700 || -6772.5200 5194.7400 || -6776.3200 5192.1000 || -6776.4300 5337.9000 || 6997.1200 5348.3300 || -7020.0900 5348.4400 || -7021.1100 Path: data2 5789322.3040 || 7500854.8800 -124.9646 || 373.4666 5789295.3170 || 7500857.7380 -151.9768 || 376.3191 5789298.8620 || 7500874.6180 -148.4337 || 393.2154 -63.0262 || 297.6930 5789369.8750 || 7500785.7170 5789303.2010 || 7500873.9300 -144.0905 || 392.5281 5789302.7240 || 7500869.9080 -144.5668 || 388.5023 5789307.5930 || 7500869.2210 -139.6932 || 387.8161 5789307.9110 || 7500871.6550 -139.3756 || 390.2524