Interesting perl One-liner

Monday, December 31, 2012 , 0 Comments

How do you double space every line in a file.I mean add an extra newline in between files.
I would have done this below:

perl -pe 's/$/\n/' your_file

I also feel that this is a clean way to do.Use a regex,replace every $(end of line) with a new line.

well there is a much coller way i found,

do you know that there is awk's ORS equivalent in perl too?
yes there is.

$\ in perl = ORS in awk

so now if i do the below,it does the same thing as the first command i mentioned at the top.

perl -pe '$\="\n"'