tests/Makefile: Show the output for all tests, don't use Genlog
[gpstools.git] / latlon
blob82a773479224e987784e3d0ffb2055e4b93ac1b7
1 #!/usr/bin/env perl
3 #=======================================================================
4 # latlon
5 # File ID: 42441484-6158-11df-b790-90e6ba3022ac
6 # Setter lat og lon på veipunkter i «riktig» rekkefølge.
8 # Character set: UTF-8
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 #=======================================================================
14 use strict;
15 use warnings;
16 use Getopt::Long;
18 $| = 1;
20 our $Debug = 0;
22 our %Opt = (
24 'debug' => 0,
25 'help' => 0,
26 'verbose' => 0,
27 'version' => 0,
31 our $progname = $0;
32 $progname =~ s/^.*\/(.*?)$/$1/;
33 our $VERSION = "0.00";
35 Getopt::Long::Configure("bundling");
36 GetOptions(
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'}) {
48 print_version();
49 exit(0);
52 while (<>) {
53 if (/^(.*?\s+)(lon="\S+")(\s+)(lat="\S+?")(>.*)/) {
54 print("$1$4$3$2$5\n");
55 } else {
56 print;
60 sub print_version {
61 # Print program version {{{
62 print("$progname v$VERSION\n");
63 # }}}
64 } # print_version()
66 sub usage {
67 # Send the help message to stdout {{{
68 my $Retval = shift;
70 if ($Opt{'verbose'}) {
71 print("\n");
72 print_version();
74 print(<<END);
76 Usage: $progname [options] [file [files [...]]]
78 Options:
80 -h, --help
81 Show this help.
82 -v, --verbose
83 Increase level of verbosity. Can be repeated.
84 --version
85 Print version information.
86 --debug
87 Print debugging messages.
89 END
90 exit($Retval);
91 # }}}
92 } # usage()
94 sub msg {
95 # Print a status message to stderr based on verbosity level {{{
96 my ($verbose_level, $Txt) = @_;
98 if ($Opt{'verbose'} >= $verbose_level) {
99 print(STDERR "$progname: $Txt\n");
101 # }}}
102 } # msg()
104 sub D {
105 # Print a debugging message {{{
106 $Debug || return;
107 my @call_info = caller;
108 chomp(my $Txt = shift);
109 my $File = $call_info[1];
110 $File =~ s#\\#/#g;
111 $File =~ s#^.*/(.*?)$#$1#;
112 print(STDERR "$File:$call_info[2] $$ $Txt\n");
113 return("");
114 # }}}
115 } # D()
117 __END__
119 # Plain Old Documentation (POD) {{{
121 =pod
123 =head1 NAME
127 =head1 SYNOPSIS
129 [options] [file [files [...]]]
131 =head1 DESCRIPTION
135 =head1 OPTIONS
137 =over 4
139 =item B<-h>, B<--help>
141 Print a brief help summary.
143 =item B<-v>, B<--verbose>
145 Increase level of verbosity. Can be repeated.
147 =item B<--version>
149 Print version information.
151 =item B<--debug>
153 Print debugging messages.
155 =back
157 =head1 BUGS
161 =head1 AUTHOR
163 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
165 =head1 COPYRIGHT
167 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
168 This is free software; see the file F<COPYING> for legalese stuff.
170 =head1 LICENCE
172 This program is free software: you can redistribute it and/or modify it
173 under the terms of the GNU General Public License as published by the
174 Free Software Foundation, either version 3 of the License, or (at your
175 option) any later version.
177 This program is distributed in the hope that it will be useful, but
178 WITHOUT ANY WARRANTY; without even the implied warranty of
179 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
180 See the GNU General Public License for more details.
182 You should have received a copy of the GNU General Public License along
183 with this program.
184 If not, see L<http://www.gnu.org/licenses/>.
186 =head1 SEE ALSO
188 =cut
190 # }}}
192 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :