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 restart depending on continuation state } else {s/\A\s*// if $c == 1; # Strip leading spaces in continuation say "$s$_"; # Write completed statement ($s, $c) = ('', 0); # Restart } } #### 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