in reply to insert line in between two lines

s/\n([^\n]*)/\n$newline$1/s;

update:'\n' removed from match pattern.

Prasad

Replies are listed 'Best First'.
Re^2: insert line in between two lines
by Anonymous Monk on Mar 16, 2005 at 11:39 UTC
    here is what to i needed specifically
    $cwd = cwd();
    print"$cwd\n";

    i want the following
    $cwd = cwd();
    $exec = $ENV{EXEC}
    print"$cwd\n";

    i am sorry for not giving detail earlier

      This might work for you.

      undef $/; $a = <DATA>; $nline =q($exec = $ENV{EXEC};); $a =~ s/\n([^\n]+)/\n$nline\n$1/s; print "$a"; __DATA__ $cwd = cwd(); print"$cwd\n";

      Prasad