Minimal Perl: For Unix And Linux People

Preparing link to download Please wait... Download

E-Book Overview

A guide to a carefully designed subset of the Perl language, this book makes Perl more accessible to those having UNIX/Linux skill levels ranging from elementary to expert by capitalizing on their existing knowledge of important utilities (grep, awk), or essential concepts (filters, command substitution, looping). Dozens of detailed programming examples are shown, drawn from contemporary application areas such as system administration, networking, Web development, databases, finance, HTML, CGI, and text analysis. Broken into two parts, the first is for all who are familiar with core UNIX/Linux commands such as grep and caters to readers ranging from managers and administrative staff to advanced programmers. The second part is for developers experienced in Bourne, Korn, Bash, or POSIX Shell programming and makes Perl scripting easy to learn by showing Shell examples along with their Perl counterparts. Many Perl modules are covered including freely available pre-written code from the CPAN.

E-Book Content

Minimal Perl For UNIX and Linux People BY TIM MAHER MANNING Greenwich (74° w. long.) For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact: Special Sales Department Manning Publications Co. Cherokee Station PO Box 20386 New York, NY 10021 Fax: (609) 877-8256 email: [email protected] ©2007 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Manning Publications Co. 209 Bruce Park Avenue Greenwich, CT 06830 Copyeditor: Tiffany Taylor Typesetters: Denis Dalinnik, Dottie Marsico Cover designer: Leslie Haimes ISBN 1-932394-50-8 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – VHG – 10 09 08 07 06 To Yeshe Dolma Sherpa, whose fortitude, endurance, and many sacrifices made this book possible. To my parents, Gloria Grady Washington and William N. Maher, who indulged my early interests in literature. To my limbic system, with gratitude for all the good times we’ve had together. brief contents Part 1 Minimal Perl: for UNIX and Linux Users 1 1 Introducing Minimal Perl 3 2 Perl essentials 16 3 Perl as a (better) grep command 53 4 Perl as a (better) sed command 89 5 Perl as a (better) awk command 121 6 Perl as a (better) find command 178 Part 2 Minimal Perl: for UNIX and Linux Shell Programmers 203 7 Built-in functions 205 8 Scripting techniques 247 9 List variables 295 10 Looping facilities 330 11 Subroutines and variable scoping 362 12 Modules and the CPAN 388 vii contents foreword xvii preface xix acknowledgments xxii about this book xxiii about the cover illustration xxxiv list of tables xxxv Part 1 Minimal Perl: for UNIX and Linux Users 1 1 Introducing Minimal Perl 1.1 A visit to Perlistan 3 3 Sometimes you need a professional guide 5 1.2 Perl can be simple 7 1.3 A