AdvAnce PrAise for Perl One-liners
“One of the slogans used by Perl is ‘Easy things should be easy and hard
things should be possible.’ This book illustrates just how easy things can be—
and how much can be done with so little code.”
—DaviD Precious, contributor to the Perl Dancer Project anD various
cPan moDules
“By reading this book you can make a step toward becoming the local
computer wizard, even without learning how to program.”
—Gabor szabo, founDer anD eDitor of the Perl Weekly newsletter
“A set of exercises for deepening your understanding of Perl.”
—john D. cook, sinGular value consultinG
“The author is enthusiastic about the material and uses an easy writing style.
Highly recommended.”
—thriG ( jeremy mates), internet Plumber
“These one-liners are great. Simple. Clear. Concise.”
—jonathan scott Duff, Perl Guru
“A quick read full of useful command-line Perl programs.”
—chris feDDe, systems enGineer anD Perl enthusiast
“Handy for anyone who does a lot of one-off text processing: system
administrators, coders, or anyone with large amounts of data they need
shifted, filtered, or interpreted.”
—jim Davis, Perl DeveloPer
Perl One-liners
Perl
One-liners
130 Programs
That Get Things Done
by Peteris Krumins
San Francisco
Perl One-liners. Copyright © 2014 by Peteris Krumins.
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic
or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the
prior written permission of the copyright owner and the publisher.
Printed in USA
First printing
17 16 15 14 13
1 2 3 4 5 6 7 8 9
ISBN-10: 1-59327-520-X
ISBN-13: 978-1-59327-520-4
Publisher: William Pollock
Production Editor: Riley Hoffman
Cover Illustration: Tina Salameh
Interior Design: Octopod Studios
Developmental Editor: William Pollock
Technical Reviewer: Alastair McGowan-Douglas
Copyeditor: LeeAnn Pickrell
Compositor: Riley Hoffman
Proofreader: Elaine Merrill
For information on distribution, translations, or bulk sales, please contact No Starch Press, Inc. directly:
No Starch Press, Inc.
245 8th Street, San Francisco, CA 94103
phone: 415.863.9900; fax: 415.863.9950; info@nostarch.com; www.nostarch.com
Library of Congress Cataloging-in-Publication Data
Krumins, Peteris.
Perl one-liners : 130 programs that get things done / by Peteris Krumins.
pages cm
Summary: "Snappy Perl programs to streamline tasks and sharpen coding skills"-- Provided by publisher.
ISBN 978-1-59327-520-4 (paperback) -- ISBN 1-59327-520-X (paperback)
1. Perl (Computer program language) I. Title.
QA76.73.P22K78 2013
005.13'3--dc23
2013030613
No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other product and
company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark
symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to
the benefit of the trademark owner, with no intention of infringement of the trademark.
The information in this book is distributed on an “As Is” basis, without warranty. While every precaution has been
taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to any
person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the infor-
mation contained in it.
About the Author
Peteris Krumins is a programmer,
systems administrator, blogger, and
all-around hacker. He is currently
running his own company, Browserling,
which focuses on cross-browser testing.
He has self-published three books on
essential UNIX tools, and he enjoys
open-sourcing hundreds of small
projects on GitHub.
Find his website and blog at
http://www.catonmat.net/, follow
@pkrumins on Twitter, and see
his open source projects at
http://github.com/pkrumins/.
About the Technical reviewer
Alastair McGowan-Douglas lives in Rugby in the UK. He has been a
Perl developer since 2008 and is now stuck writing PHP for a living.
His favorite pastime at work is writing Perl scripts for internal use to
encourage others to embrace the language. Also a JavaScript developer
and Git aficionado, his rantings and musings on these various subjects
can be found at http://altreus.blogspot.com/.