3 #=======================================================================
5 # File ID: d16a06e8-6138-11df-8aac-90e6ba3022ac
9 # ©opyleft 2010– Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 3 or later, see end of
11 # file for legal stuff.
12 #=======================================================================
32 $progname =~ s/^.*\/(.*?)$/$1/;
33 our $VERSION = "0.00";
35 Getopt
::Long
::Configure
("bundling");
38 "debug" => \
$Opt{'debug'},
39 "help|h" => \
$Opt{'help'},
40 "verbose|v+" => \
$Opt{'verbose'},
41 "version" => \
$Opt{'version'},
43 ) || die("$progname: Option error. Use -h for help.\n");
45 $Opt{'debug'} && ($Debug = 1);
46 $Opt{'help'} && usage
(0);
47 if ($Opt{'version'}) {
53 if (/(.*?<(?:trkpt|rtept|wpt)\s+.*?)"(.*?)"(.*?)"(.*?)"(.*)$/) {
54 my ($num1, $num2) = (sprintf("%.6f", $2), sprintf("%.6f", $4));
55 print("$1\"" . num_expand
($num1) . "\"$3\"" . num_expand
($num2) . "\"$5\n");
56 } elsif (/^(.*?<ele>)(-?[\d\.]+)(<\/ele
>.*)$/) {
57 my $ele = sprintf("%.3f", $2);
58 print($1 . num_expand
($ele) . "$3\n");
65 # Convert scientific notation to decimal notation {{{
67 length($Retval) || return("");
68 if ($Retval =~ /^(.*)e([-+]?)(.*)$/) {
69 my ($num, $sign, $exp) = ($1, $2, $3);
70 my $sig = $sign eq '-' ?
"." . ($exp - 1 + length $num) : '';
71 $Retval = sprintf("%${sig}f", $Retval);
74 my $minus = ($Retval =~ s/^-//) ?
"-" : "";
75 if ($Retval =~ /\.\d/) {
78 $Retval =~ s/^0([1-9]+)\./$1./;
83 length($Retval) || ($Retval = 0);
84 $Retval = $Retval ?
"$minus$Retval" : 0;
90 # Print program version {{{
91 print("$progname v$VERSION\n");
96 # Send the help message to stdout {{{
99 if ($Opt{'verbose'}) {
105 Usage: $progname [options] [file [files [...]]]
112 Increase level of verbosity. Can be repeated.
114 Print version information.
116 Print debugging messages.
124 # Print a status message to stderr based on verbosity level {{{
125 my ($verbose_level, $Txt) = @_;
127 if ($Opt{'verbose'} >= $verbose_level) {
128 print(STDERR
"$progname: $Txt\n");
134 # Print a debugging message {{{
136 my @call_info = caller;
137 chomp(my $Txt = shift);
138 my $File = $call_info[1];
140 $File =~ s
#^.*/(.*?)$#$1#;
141 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
148 # Plain Old Documentation (POD) {{{
158 [options] [file [files [...]]]
168 =item B<-h>, B<--help>
170 Print a brief help summary.
172 =item B<-v>, B<--verbose>
174 Increase level of verbosity. Can be repeated.
178 Print version information.
182 Print debugging messages.
192 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
196 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
197 This is free software; see the file F<COPYING> for legalese stuff.
201 This program is free software: you can redistribute it and/or modify it
202 under the terms of the GNU General Public License as published by the
203 Free Software Foundation, either version 3 of the License, or (at your
204 option) any later version.
206 This program is distributed in the hope that it will be useful, but
207 WITHOUT ANY WARRANTY; without even the implied warranty of
208 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
209 See the GNU General Public License for more details.
211 You should have received a copy of the GNU General Public License along
213 If not, see L<http://www.gnu.org/licenses/>.
221 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :