Skip to Content
Perl One-Liners
book

Perl One-Liners

by Peteris Krumins
December 2013
Intermediate to advanced
168 pages
2h 49m
English
No Starch Press
Content preview from Perl One-Liners

Appendix C. Perl1Line.Txt

As I was writing this book, I compiled all the one-liners in a file called perl1line.txt. This appendix is that file. It comes in very handy when you need to quickly look up a one-liner. You can just open perl1line.txt in a text editor and search for the action you want to perform. The latest version of this file can always be found at http://www.catonmat.net/download/perl1line.txt.

C.1 Spacing

Double-space a file

perl -pe '$\ = "\n"'
perl -pe 'BEGIN { $\ = "\n" }'
perl -pe '$_ .= "\n"'
perl -pe 's/$/\n/'
perl -nE 'say'

Double-space a file, excluding the blank lines

perl -pe '$_ .= "\n" unless /^$/'
perl -pe '$_ .= "\n" if /\S/'

Triple-space a file

perl -pe '$\ = "\n\n"'
perl -pe '$_ .= "\n\n"'
perl -pe 's/$/\n\n/'

N-space a ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Perl Best Practices

Perl Best Practices

Damian Conway
Perl Cookbook

Perl Cookbook

Tom Christiansen, Nathan Torkington
Minimal Perl

Minimal Perl

Tim Maher
Learning Perl, 7th Edition

Learning Perl, 7th Edition

Randal L. Schwartz, brian d foy, Tom Phoenix

Publisher Resources

ISBN: 9781457185281Errata