#! /usr/bin/perl use strict; use warnings; my $filename = './test.vrml'; open my $FH, '<', $filename or die "Can't open $filename for reading: $!"; my @data = <$FH>; # Read the contents of the file into an array close $FH; my @coordinates; foreach my $line ( @data ) { if ( my ($lat, $lon) = ( $line =~ m/\{\s*(.*), (.*)\s*\}/) ) { push @coordinates, "$1 $2"; } } print "COORDINATES: $_\n" foreach ( @coordinates );