in reply to how to access GPX data

use List::Util qw[sum]; foreach my $track (@$tracks) { my @points = map { @{$_->{points}} } @{ $track->{segments} }; my $count_of_points = @points; my $total_elevation = sum 0, map { $_->{ele} } @points; my $average = $total_elevation / $count_of_points; printf "%s = %d\n", $track->{name}, $average; }

Though I get 69 for the average elevation of Track 1. You seem to be ignoring the fourth measurement (63.0). My code above does not ignore that.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: how to access GPX data
by geogpx (Initiate) on May 27, 2012 at 13:45 UTC
    Thnx! that works great :) and yes, you're right about the average of track 1