in reply to insert line in between two lines

undef $/; open(IN, "< 1.txt") ; $str = <IN>; close(IN); $str =~ s#\n(.+?)\n#\n\$exec \= \$ENV\{EXEC\}\n$1\n#gsi; open(OUT, "> 2.txt") ; print OUT $str; input: ********* hai this is the test input sample output: ********** hai $exec = $ENV{EXEC} this is $exec = $ENV{EXEC} the test $exec = $ENV{EXEC} input sample

Replies are listed 'Best First'.
Re^2: insert line in between two lines
by Anonymous Monk on Mar 16, 2005 at 12:17 UTC
    perlsen thanks, but as i told earlier that i need to add
    $exec = $ENV{EXEC}
    only once in between
    $cwd=cwd();
    and
    print"$cwd\n"; i hope you will get what i want .

      Remove 'g' option modifier for that.

      Prasad