Skip to content

Instantly share code, notes, and snippets.

@odyniec
Created January 25, 2013 00:46
Show Gist options
  • Save odyniec/4630468 to your computer and use it in GitHub Desktop.
Save odyniec/4630468 to your computer and use it in GitHub Desktop.
A Perl oneliner (with a shell alias) that calculates the average running pace based on distance and time.
# A Perl oneliner (with a shell alias) that calculates the average running pace based on distance and time
# Examples:
# pace 5 28:05 # 5 kilometres, 28 minutes and 5 seconds
# pace 10.5 45:28 # 10.5 kilometres, 45 minutes and 28 seconds
# pace 42.195 2:03:38 # Marathon, 2 hours, 3 minutes and 38 seconds (current WR)
alias pace="perl -e 'map{\$t+=\$_*60**\$i++}reverse split/:/,pop;\$t/=pop;printf\"%d:%02d\n\",\$t/60,\$t%60'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment