in reply to how to append 2 lines
Something along the lines of:
use feature ":5.14"; use warnings FATAL => qw(all); use strict; my ($c, $s) = (0, ''); for(split /\n/, << 'END') LABEL#00001 MVC SYMBOL+2(4),X.PDES_KEY+2 + MVC SYMB_ART,=C'XSEQ' //line comments + + F$SFH SELECT,LISTING, + * DESKART=SYMB_ART, + * DESKWERT=SYMBOL, + * MARKTCODE=L#MACF + BNE F03#000 //line comments END {if (length > 71 and substr($_, 71, 1) eq '*') # Detect continuation {s/\A\s*// if $c == 1; # Strip leading space +in continuation s/\s*\*\s*\Z//; # Strip trailing space ($s, $c) = (($c ? $s : '').$_, 1); # Concatenate or resta +rt depending on continuation state } else {s/\A\s*// if $c == 1; # Strip leading spaces + in continuation say "$s$_"; # Write completed stat +ement ($s, $c) = ('', 0); # Restart } }
Produces
LABEL#00001 MVC SYMBOL+2(4),X.PDES_KEY+2 + MVC SYMB_ART,=C'XSEQ' //line comments + + F$SFH SELECT,LISTING,DESKART=SYMB_ART,DESKWERT=SYMBOL,MARKTCO +DE=L#MACF BNE F03#000 //line comments
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to append 2 lines
by suno (Acolyte) on Sep 05, 2012 at 12:18 UTC | |
by philiprbrenan (Monk) on Sep 05, 2012 at 21:43 UTC | |
by suno (Acolyte) on Sep 10, 2012 at 10:26 UTC |