coord Coordinate { 12 23 45, 14 16 65 }
coord Coordinate { 13 34 57, 14 17 55 }
coord Coordinate { 14 33 34, 14 15 40 }
####
#! /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 );
####
COORDINATES: 12 23 45 14 16 65
COORDINATES: 13 34 57 14 17 55
COORDINATES: 14 33 34 14 15 40
####
my $output_filename = './test.cpp';
open $OUTPUT, '>', $output_filename or die "Can't open $output_filename for writing: $!";
foreach ( @data ) {
print { $OUTPUT } "$_\n"; # Print to file
}
close $OUTPUT;