http://www.perlmonks.org?node_id=990969


in reply to Re: how to append 2 lines
in thread how to append 2 lines

Hi,here is the sample input code...

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

my required output should be somewhat like this...

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^3: how to append 2 lines
by aitap (Curate) on Aug 31, 2012 at 10:32 UTC

    And your Perl code to join the lines is...

    Hint: use three-argument form of substr to check the 72nd symbol of the line and use it again to replace the text. For example:

    my $one = ("_"x9)."*__\n"; my $two = ("-"x15)."\n"; print "$one$two"; substr($one,9)="" if substr($one,9,1) eq "*"; print "$one$two";

    Sorry if my advice was wrong.
Re^3: how to append 2 lines
by Anonymous Monk on Aug 31, 2012 at 10:30 UTC
    Ok, but that is only DATA, that is not perl