#!/usr/local/bin/perl -w use strict; use Template; use YAML qw( Load ); my $trip = Load( join "", <> ); my $data = join "", ; my $mappoints = join ", ", map { mappoint( $_->{ lat }, $_->{ lon } ) } @$trip; if( scalar @$trip <= 1 ) { die "Need at least one track point"; } my $first = $trip->[0]; my $center = mappoint( $first->{ lat }, $first->{ lon } ); my $tmpl = Template->new; $tmpl->process( \$data, { mappoints => $mappoints, center => $center } ) or die $tmpl->error(); sub mappoint { my( $lat, $lon ) = @_; return "new google.maps.LatLng( $lat, $lon )"; } __DATA__