From 1facb0870628739ed3bf6659dc26fa75ca54a447 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20A=2E=20Holm?= Date: Mon, 12 Mar 2012 23:46:38 +0100 Subject: [PATCH] wpt-line: Add -e/--element option 49eee1d8-6c95-11e1-adc4-0f709619b7e0 --- wpt-line | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wpt-line b/wpt-line index aa6848c..5a02102 100755 --- a/wpt-line +++ b/wpt-line @@ -3,7 +3,7 @@ #======================================================================= # wpt-line # File ID: c1b91d20-621b-11e1-8d08-23fe5446b5f1 -# Convert elements to/from single lines +# Convert or other elements to/from single lines # # Character set: UTF-8 # ©opyleft 2012– Øyvind A. Holm @@ -22,6 +22,7 @@ our $Debug = 0; our %Opt = ( 'debug' => 0, + 'element' => 'wpt', 'help' => 0, 'split' => 0, 'verbose' => 0, @@ -37,6 +38,7 @@ Getopt::Long::Configure('bundling'); GetOptions( 'debug' => \$Opt{'debug'}, + 'element|e=s' => \$Opt{'element'}, 'help|h' => \$Opt{'help'}, 'split|s' => \$Opt{'split'}, 'verbose|v+' => \$Opt{'verbose'}, @@ -56,7 +58,7 @@ my $slurp = join('', <>); if ($Opt{'split'}) { $slurp =~ s/&lf;/\n/gs; } else { - $slurp =~ s/()/oneline($1)/gse; + $slurp =~ s/(<$Opt{'element'}\b.*?<\/$Opt{'element'}>)/oneline($1)/gse; } print $slurp; @@ -86,10 +88,13 @@ sub usage { Usage: $progname [options] [file [files [...]]] -Convert to/from single lines. For removing duplicates, etc. +Convert or other elements to/from single lines. For removing +duplicates, etc. Options: + -e X, --element X + Convert lines between element X. Default: 'wpt'. -h, --help Show this help. -s, --split -- 2.11.4.GIT