in reply to insert line of text above a line

uh..
perl -pe"if($_eq'baz-123'){print'bar=2'}" old_file.txt > new_file.txt

Replies are listed 'Best First'.
Re: Re: insert line of text above a line
by Anonymous Monk on Sep 25, 2003 at 22:57 UTC
    uh..

    C:\>perl -pe"if($_eq'baz-123'){print'bar=2'}" old > new String found where operator expected at -e line 1, near "123'){print'" (Missing operator before '){print'?) Bareword found where operator expected at -e line 1, near "'){print'ba +r" (Missing operator before bar?) String found where operator expected at -e line 1, at end of line (Missing semicolon on previous line?) syntax error at -e line 1, near "123'){print'" Can't find string terminator "'" anywhere before EOF at -e line 1.

    Why not use the -i command line option?
    Since baz is the only constant, it should be =~ /baz/ and not eq
    print 'bar=2' wtf is the newline?
    Thanks for broken code that would not do the job even if it worked

      So he forgot a space in $_hereeq, and he doesn't print a single newline, big f-ing deal (no need to be rude).