I'm trying to add "
at beginning and ",
at end of each non-empty line of text file in Perl.
perl -pi -e 's/^(.+)$/\"$1\",/g' something.txt
It adds "
at beginning of each non-empty line, but i have problem with ",
.
Example input:
bla
bla bla
blah
That's output i'm getting:
"bla
",
"bla bla
",
"blah
",
And that's output i actually want:
"bla",
"bla bla",
"blah",
How do I fix this?
Edit:
I opened my output file in vim now (I opened it in kwrite before so it wasn't visible) and I noticed vim shows ^M
before each ",
- I don't know what in code adds this.