perl escaping \n or \t

Posted by Michael on Stack Overflow See other posts from Stack Overflow or by Michael
Published on 2010-05-13T14:06:13Z Indexed on 2010/05/13 14:44 UTC
Read the original article Hit count: 421

Filed under:
|

I need to escape \n so on output I really get newline or tab

$ perl -p -e 's/e/a/ge'

now I want each e to be substituted with \n

$ perl -p -e 's/e/\n/ge'

but even \n gives me an error.

this was a simplified example. In real script(makefile) I have

substitute := perl -p -e 's/@([^@]+)@/defined $$ENV{$$1} ? $$ENV{$$1} : $$1/ge'

and in target I have such a nice command

$(substitute) $< > $@

and if the input file for perl contains \n at output I will see it literally... I want to have real newline.

© Stack Overflow or respective owner

Related posts about perl

Related posts about regex