3 #=======================================================================
5 # File ID: c1b91d20-621b-11e1-8d08-23fe5446b5f1
6 # Convert <wpt> or other elements to/from single lines
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 #=======================================================================
34 $progname =~ s/^.*\/(.*?)$/$1/;
35 our $VERSION = '0.00';
37 Getopt
::Long
::Configure
('bundling');
40 'debug' => \
$Opt{'debug'},
41 'element|e=s' => \
$Opt{'element'},
42 'help|h' => \
$Opt{'help'},
43 'split|s' => \
$Opt{'split'},
44 'verbose|v+' => \
$Opt{'verbose'},
45 'version' => \
$Opt{'version'},
47 ) || die("$progname: Option error. Use -h for help.\n");
49 $Opt{'debug'} && ($Debug = 1);
50 $Opt{'help'} && usage
(0);
51 if ($Opt{'version'}) {
56 my $slurp = join('', <>);
59 $slurp =~ s/&lf;/\n/gs;
61 $slurp =~ s/(<$Opt{'element'}\b.*?<\/$Opt{'element'}>)/oneline
($1)/gse
;
73 # Print program version {{{
74 print("$progname v$VERSION\n");
80 # Send the help message to stdout {{{
83 if ($Opt{'verbose'}) {
89 Usage: $progname [options] [file [files [...]]]
91 Convert <wpt> or other elements to/from single lines. For removing
97 Convert lines between element X. Default: 'wpt'.
101 Split oneliners into several lines again.
103 Increase level of verbosity. Can be repeated.
105 Print version information.
107 Print debugging messages.
115 # Print a status message to stderr based on verbosity level {{{
116 my ($verbose_level, $Txt) = @_;
118 if ($Opt{'verbose'} >= $verbose_level) {
119 print(STDERR
"$progname: $Txt\n");
126 # Print a debugging message {{{
128 my @call_info = caller;
129 chomp(my $Txt = shift);
130 my $File = $call_info[1];
132 $File =~ s
#^.*/(.*?)$#$1#;
133 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
140 # Plain Old Documentation (POD) {{{
150 [options] [file [files [...]]]
160 =item B<-h>, B<--help>
162 Print a brief help summary.
164 =item B<-v>, B<--verbose>
166 Increase level of verbosity. Can be repeated.
170 Print version information.
174 Print debugging messages.
184 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
188 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
189 This is free software; see the file F<COPYING> for legalese stuff.
193 This program is free software: you can redistribute it and/or modify it
194 under the terms of the GNU General Public License as published by the
195 Free Software Foundation, either version 3 of the License, or (at your
196 option) any later version.
198 This program is distributed in the hope that it will be useful, but
199 WITHOUT ANY WARRANTY; without even the implied warranty of
200 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
201 See the GNU General Public License for more details.
203 You should have received a copy of the GNU General Public License along
205 If not, see L<http://www.gnu.org/licenses/>.
213 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :