$ std -l perl wpt-dupdesc
[gpstools.git] / wpt-dupdesc
blobffca76dc312a7fff21ddb61c2c5b0d858ceea0bc
1 #!/usr/bin/perl
3 #=======================================================================
4 # wpt-dupdesc
5 # File ID: c3b793a4-6225-11e1-bae9-37679d2dbe43
6 # [Description]
8 # Character set: UTF-8
9 # ©opyleft 2012– Ø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 local $| = 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 print;
56 sub print_version {
57 # Print program version {{{
58 print("$progname v$VERSION\n");
59 return;
60 # }}}
61 } # print_version()
63 sub usage {
64 # Send the help message to stdout {{{
65 my $Retval = shift;
67 if ($Opt{'verbose'}) {
68 print("\n");
69 print_version();
71 print(<<"END");
73 Usage: $progname [options] [file [files [...]]]
75 Options:
77 -h, --help
78 Show this help.
79 -v, --verbose
80 Increase level of verbosity. Can be repeated.
81 --version
82 Print version information.
83 --debug
84 Print debugging messages.
86 END
87 exit($Retval);
88 # }}}
89 } # usage()
91 sub msg {
92 # Print a status message to stderr based on verbosity level {{{
93 my ($verbose_level, $Txt) = @_;
95 if ($Opt{'verbose'} >= $verbose_level) {
96 print(STDERR "$progname: $Txt\n");
98 return;
99 # }}}
100 } # msg()
102 sub D {
103 # Print a debugging message {{{
104 $Debug || return;
105 my @call_info = caller;
106 chomp(my $Txt = shift);
107 my $File = $call_info[1];
108 $File =~ s#\\#/#g;
109 $File =~ s#^.*/(.*?)$#$1#;
110 print(STDERR "$File:$call_info[2] $$ $Txt\n");
111 return('');
112 # }}}
113 } # D()
115 __END__
117 # Plain Old Documentation (POD) {{{
119 =pod
121 =head1 NAME
125 =head1 SYNOPSIS
127 [options] [file [files [...]]]
129 =head1 DESCRIPTION
133 =head1 OPTIONS
135 =over 4
137 =item B<-h>, B<--help>
139 Print a brief help summary.
141 =item B<-v>, B<--verbose>
143 Increase level of verbosity. Can be repeated.
145 =item B<--version>
147 Print version information.
149 =item B<--debug>
151 Print debugging messages.
153 =back
155 =head1 BUGS
159 =head1 AUTHOR
161 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
163 =head1 COPYRIGHT
165 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
166 This is free software; see the file F<COPYING> for legalese stuff.
168 =head1 LICENCE
170 This program is free software: you can redistribute it and/or modify it
171 under the terms of the GNU General Public License as published by the
172 Free Software Foundation, either version 3 of the License, or (at your
173 option) any later version.
175 This program is distributed in the hope that it will be useful, but
176 WITHOUT ANY WARRANTY; without even the implied warranty of
177 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
178 See the GNU General Public License for more details.
180 You should have received a copy of the GNU General Public License along
181 with this program.
182 If not, see L<http://www.gnu.org/licenses/>.
184 =head1 SEE ALSO
186 =cut
188 # }}}
190 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :