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 #=======================================================================
31 $progname =~ s/^.*\/(.*?)$/$1/;
32 our $VERSION = "0.00";
34 Getopt
::Long
::Configure
("bundling");
37 "debug" => \
$Opt{'debug'},
38 "help|h" => \
$Opt{'help'},
39 "verbose|v+" => \
$Opt{'verbose'},
40 "version" => \
$Opt{'version'},
42 ) || die("$progname: Option error. Use -h for help.\n");
44 $Opt{'debug'} && ($Debug = 1);
45 $Opt{'help'} && usage
(0);
46 if ($Opt{'version'}) {
52 if (/(.*?<(?:trkpt|rtept|wpt)\s+.*?)"(.*?)"(.*?)"(.*?)"(.*)$/) {
53 my ($num1, $num2) = (sprintf("%.6f", $2), sprintf("%.6f", $4));
54 print("$1\"" . num_expand
($num1) . "\"$3\"" . num_expand
($num2) . "\"$5\n");
55 } elsif (/^(.*?<ele>)(-?[\d\.]+)(<\/ele
>.*)$/) {
56 my $ele = sprintf("%.3f", $2);
57 print($1 . num_expand
($ele) . "$3\n");
64 # Convert scientific notation to decimal notation {{{
66 length($Retval) || return("");
67 if ($Retval =~ /^(.*)e([-+]?)(.*)$/) {
68 my ($num, $sign, $exp) = ($1, $2, $3);
69 my $sig = $sign eq '-' ?
"." . ($exp - 1 + length $num) : '';
70 $Retval = sprintf("%${sig}f", $Retval);
73 my $minus = ($Retval =~ s/^-//) ?
"-" : "";
74 if ($Retval =~ /\.\d/) {
77 $Retval =~ s/^0([1-9]+)\./$1./;
82 length($Retval) || ($Retval = 0);
83 $Retval = $Retval ?
"$minus$Retval" : 0;
89 # Print program version {{{
90 print("$progname v$VERSION\n");
95 # Send the help message to stdout {{{
98 if ($Opt{'verbose'}) {
104 Usage: $progname [options] [file [files [...]]]
111 Increase level of verbosity. Can be repeated.
113 Print version information.
115 Print debugging messages.
123 # Print a status message to stderr based on verbosity level {{{
124 my ($verbose_level, $Txt) = @_;
126 if ($Opt{'verbose'} >= $verbose_level) {
127 print(STDERR
"$progname: $Txt\n");
133 # Print a debugging message {{{
135 my @call_info = caller;
136 chomp(my $Txt = shift);
137 my $File = $call_info[1];
139 $File =~ s
#^.*/(.*?)$#$1#;
140 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
147 # Plain Old Documentation (POD) {{{
157 [options] [file [files [...]]]
167 =item B<-h>, B<--help>
169 Print a brief help summary.
171 =item B<-v>, B<--verbose>
173 Increase level of verbosity. Can be repeated.
177 Print version information.
181 Print debugging messages.
191 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
195 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
196 This is free software; see the file F<COPYING> for legalese stuff.
200 This program is free software: you can redistribute it and/or modify it
201 under the terms of the GNU General Public License as published by the
202 Free Software Foundation, either version 3 of the License, or (at your
203 option) any later version.
205 This program is distributed in the hope that it will be useful, but
206 WITHOUT ANY WARRANTY; without even the implied warranty of
207 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
208 See the GNU General Public License for more details.
210 You should have received a copy of the GNU General Public License along
212 If not, see L<http://www.gnu.org/licenses/>.
220 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :