Below is a perl script that will process track data exported from a Garmin GPS using Garmin's BaseCamp software.

Lines that start with a "#" are comments I've made to help explain the logic flow

I've added the routines to count the total elevation gain and loss (Up and Down) and the necessary variables are loaded to do the math to calculate the total on the ground mileage for a track. All we need is the math.

If you guys can show me how to do that I'll try and write the code for it.

---------- code starts below ----------

#!/usr/bin/perl

#############################################################
#############################################################
#
# Calc Miles Hiked v1.0"
#
#############################################################
# We use these fine modules...
use strict;
use warnings;

# an example of tab seperated values that we can export from a Garmin GPS
# the values are: lat long elevation timestamp
# we add each line of the data to an array of data

my @input = (
'36.663116030395031 -92.902936963364482 353.899999999999977 2011-12-30T22:19:27Z',
'36.663144025951624 -92.902942998334765 354.860000000000014 2011-12-30T22:19:39Z',
'36.663215020671487 -92.902968982234597 358.70999999999998 2011-12-30T22:20:08Z',
'36.663261959329247 -92.902940986678004 360.149999999999977 2011-12-30T22:20:23Z',
'36.663261037319899 -92.902955990284681 359.670000000000016 2011-12-30T22:21:10Z'
);

# the number of lines of data in our data file
my $number_of_lines = @input;

# we subtract by one so we can sync this number up with array order (it's a perl thing)
$number_of_lines = ($number_of_lines - 1);

#set our total up and down values to zero
my $totalUp = 0;
my $totalDown = 0;

#create a line counter so we know when to exit the while loop.
my $line_counter=0;

# now we start going over the data
# on the first pass we grab the first and next lines
# we increment the line number we start with on each pass
while ($line_counter < $number_of_lines) {

my ($latA, $lonA, $eleA, $timeA) = split(/\t/, $input[$line_counter]);

$line_counter++;

my ($latB, $lonB, $eleB, $timeB) = split(/\t/, $input[$line_counter]);


# now we have our data. here's the routine to count the total feet down we climbed

if ($eleB < $eleA) {

my $difference = ($eleA - $eleB);

$totalDown = ($totalDown - $difference);

}

# here's the routine to count the total feet up we climbed
if ($eleB > $eleA) {

my $difference = ($eleB - $eleA);

$totalUp = ($totalUp + $difference);

}

# here's where we need the math to figure total miles actually hiked.


}

# now we are all done so we print the results

print "Total Up: $totalUp \n";
print "Total Down: $totalDown \n";

######################################################
# Here's the printed output:
#
# Total Up: 6.25
# Total Down: -0.479999999999961
######################################################
_________________________
--

"You want to go where?"