ebook img

Perl one-liners : 130 programs that get things done PDF

171 Pages·2014·3.868 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Perl one-liners : 130 programs that get things done

113300 TTIIMMEE--SSAAVVIINNGG,, PPRROOBBLLEEMM--SSOOLLVVIINNGG PP EE RR LL PPEERRLL SSCCRRIIPPTTSS TTHHAATT GGEETT TTHHIINNGGSS DDOONNEE OO NN EE-- LL II NN EE RR SS Part of the fun of programming in Perl lies in tackling • Add or remove spaces 1 3 0 P R O G R A M S T H A T G E T T H I N G S D O N E PP tedious tasks with short, efficient, and reusable code. • Number lines in a file Often, the perfect tool is the one-liner, a small but EE powerful program that fits in one line of code and • Print lines that match a specific pattern RR P E T E R I S K R U M I N S does one thing really well. • Check to see if a number is prime with a regular LL In Perl One-Liners, author and impatient hacker expression Peteris Krumins takes you through more than 100 com- • Convert IP addresses to decimal form OO pelling one-liners that do all sorts of handy things, such as manipulate line spacing, tally column values in a • Replace one string with another NN table, and get a list of users on a system. This cook- And many more! Save time and sharpen your coding EE book of useful, customizable, and fun scripts will even help hone your Perl coding skills, as Krumins dissects skills as you learn to conquer those pesky tasks in a -- few precisely placed keystrokes with Perl One-Liners. the code to give you a deeper understanding of the LL language. II ABOUT THE AUTHOR NN You’ll find one-liners that: Peteris Krumins is a programmer, systems administra- • Encode, decode, and convert strings EE tor, start-up manager, and all-around hacker. He is the cofounder of Browserling and Testling, and he runs RR • Generate random passwords the popular programming blog catonmat (http:// SS • Calculate sums, factorials, and the mathematical www.catonmat.net/). constants � and e THE FINEST IN GEEK ENTERTAINMENT™ www.nostarch.com “I LIE FLAT.” $24.95 ($25.95 CDN) This book uses a lay-flat binding that won't snap shut. PROGRAMMSHELVE IN: IN G LAN G UAG ES/PERL 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 P e r l O n e -li n e r s 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 Second printing 18 17 16 15 14 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; [email protected]; 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/.

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.