Snort for Dummies.Pdf

Total Page:16

File Type:pdf, Size:1020Kb

Snort for Dummies.Pdf 01_568353 ffirs.qxd 6/3/04 10:07 AM Page i Snort ™ FOR DUMmIES‰ 01_568353 ffirs.qxd 6/3/04 10:07 AM Page ii 01_568353 ffirs.qxd 6/3/04 10:07 AM Page iii Snort ™ FOR DUMmIES‰ by Charlie Scott, Paul Wolfe, and Bert Hayes 01_568353 ffirs.qxd 6/3/04 10:07 AM Page iv Snort™ For Dummies® Published by Wiley Publishing, Inc. 111 River Street Hoboken, NJ 07030-5774 Copyright © 2004 by Wiley Publishing, Inc., Indianapolis, Indiana Published by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permis- sion of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, e-mail: brandreview@ wiley.com. Trademarks: Wiley, the Wiley Publishing logo, For Dummies, the Dummies Man logo, A Reference for the Rest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy Way, Dummies.com, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates in the United States and other countries, and may not be used without written permission. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. GENERAL DISCLAIMER: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WAR- RANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERV- ICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ. For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S. at 800-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Library of Congress Control Number: 2004102600 ISBN: 0-7645-6835-3 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 1O/SS/QW/QU/IN 01_568353 ffirs.qxd 6/3/04 10:07 AM Page v About the Authors Charlie Scott is an Information Security Analyst for the City of Austin, where he helps maintain the City’s network security infrastructure and helps analyze intrusion detection data. He has nearly ten years of experience in the Internet industry and has been an avid user of open source security software that entire time. Charlie is a Certified Information Systems Security Professional (CISSP) and a Cisco Certified Network Professional (CCNP). Bert Hayes is a Security Technical Analyst for the State of Texas, where he maintains network security for a medium sized agency. In Bert’s ten years of IT industry experience, he has done everything from managing a corporate IT shop during a successful IPO to performing white hat penetration tests for corporate and government offices. He has long been a proponent of open source solutions, and is a Red Hat Certified Engineer (RHCE). Paul Wolfe is an independent information security consultant and author, specializing in open source security. 01_568353 ffirs.qxd 6/3/04 10:07 AM Page vi 01_568353 ffirs.qxd 6/3/04 10:07 AM Page vii Authors’ Acknowledgments This book benefited greatly from the research and writing contribution of Mike Erwin, an early collaborator on this project. Mike is the president and CEO of Symbiot, Inc., a developer of intelligent security infrastructure man- agement system designed to interoperate with intrusion detection systems and other pieces of security infrastructure. Mike has fifteen years of experi- ence in network operations and security, has co-authored over a half-dozen books, and is a Certified Information Systems Security Professional (CISSP). The authors collectively bow to the developers of the myriad of security tools covered in this book, especially Marty Roesch, for answering our ques- tions and creating Snort in the first place! The authors also thank Melody Layne, Pat O’Brien, and the rest of the Wiley team for their hard work and prodding, and our agent Carole McClendon of Waterside Productions. They also thank Jamie Pugh of Symbiot for his inci- sive technical review. Bert dedicates his portion of the book to everyone who would rather build his or her own system than buy one off the shelf. He also acknowledges the unwavering love and support of his wife Kate, the loyalty of his pets, and the wisdom of his parents. Paul thanks Nikolaus, Lukas, Rayna, Jesse and Brenda, whose support make his work possible (and necessary . .). And finally, thanks to Charlie for ruling this project with the iron grip of a dictator. Bastard. Charlie dedicates his portion of the book to everyone who has ever had to clean up a cracked system — may it never happen again. He thanks his won- derful wife, Mary, and his co-workers at the City of Austin for their support. 01_568353 ffirs.qxd 6/3/04 10:07 AM Page viii Publisher’s Acknowledgments We’re proud of this book; please send us your comments through our online registration form located at www.dummies.com/register/. Some of the people who helped bring this book to market include the following: Acquisitions, Editorial, and Composition Media Development Project Coordinator: Courtney MacIntyre Project Editor: Pat O’Brien Layout and Graphics: Andrea Dahl, Acquisitions Editor: Melody Layne Stephanie D. Jumper, Lynsey Osborn, Copy Editor: Barry Childs-Helton Heather Ryan Technical Editor: Jamie Pugh Proofreaders: Laura Albert, David Faust, Andy Hollandbeck, Brian H. Walls, Editorial Manager: Kevin Kirschner TECHBOOKS Production Services Media Development Manager: Indexer: TECHBOOKS Production Services Laura VanWinkle Media Development Supervisor: Richard Graves Editorial Assistant: Amanda Foxworth Cartoons: Rich Tennant (www.the5thwave.com) Publishing and Editorial for Technology Dummies Richard Swadley, Vice President and Executive Group Publisher Andy Cummings, Vice President and Publisher Mary C. Corder, Editorial Director Publishing for Consumer Dummies Diane Graves Steele, Vice President and Publisher Joyce Pepple, Acquisitions Director Composition Services Gerry Fahey, Vice President of Production Services Debbie Stailey, Director of Composition Services 02_568353 ftoc.qxd 6/2/04 9:17 AM Page ix Contents at a Glance Introduction .................................................................1 Part I: Getting to Know Snort and Intrusion Detection .....5 Chapter 1: Looking Up Snort’s Nose ................................................................................7 Chapter 2: Fitting In Snort ...............................................................................................19 Chapter 3: Readying Your Preflight Checklist...............................................................29 Chapter 4: Makin’ Bacon: Installing Snort for Linux ....................................................41 Chapter 5: Installing Snort and MySQL for Windows...................................................77 Part II: Administering Your Snort Box.........................105 Chapter 6: Snorting Through Logs and Alerts............................................................107 Chapter 7: Adding Visuals and Getting Reports.........................................................133 Chapter 8: Making Your Own Rules..............................................................................175 Chapter 9: What, Me Worry?.........................................................................................199 Chapter 10: Dealing with the Real Thing .....................................................................217 Part III: Moving Beyond the Basics............................241 Chapter 11: Reacting in Real Time ...............................................................................243 Chapter 12: Keeping Snort Up to Date.........................................................................263 Chapter 13: Filling Your Farm with Pigs ......................................................................275 Chapter 14: Using the Barnyard Output Tool .............................................................295
Recommended publications
  • [PDF] Beginning Raku
    Beginning Raku Arne Sommer Version 1.00, 22.12.2019 Table of Contents Introduction. 1 The Little Print . 1 Reading Tips . 2 Content . 3 1. About Raku. 5 1.1. Rakudo. 5 1.2. Running Raku in the browser . 6 1.3. REPL. 6 1.4. One Liners . 8 1.5. Running Programs . 9 1.6. Error messages . 9 1.7. use v6. 10 1.8. Documentation . 10 1.9. More Information. 13 1.10. Speed . 13 2. Variables, Operators, Values and Procedures. 15 2.1. Output with say and print . 15 2.2. Variables . 15 2.3. Comments. 17 2.4. Non-destructive operators . 18 2.5. Numerical Operators . 19 2.6. Operator Precedence . 20 2.7. Values . 22 2.8. Variable Names . 24 2.9. constant. 26 2.10. Sigilless variables . 26 2.11. True and False. 27 2.12. // . 29 3. The Type System. 31 3.1. Strong Typing . 31 3.2. ^mro (Method Resolution Order) . 33 3.3. Everything is an Object . 34 3.4. Special Values . 36 3.5. :D (Defined Adverb) . 38 3.6. Type Conversion . 39 3.7. Comparison Operators . 42 4. Control Flow . 47 4.1. Blocks. 47 4.2. Ranges (A Short Introduction). 47 4.3. loop . 48 4.4. for . 49 4.5. Infinite Loops. 53 4.6. while . 53 4.7. until . 54 4.8. repeat while . 55 4.9. repeat until. 55 4.10. Loop Summary . 56 4.11. if . ..
    [Show full text]
  • EN-Google Hacks.Pdf
    Table of Contents Credits Foreword Preface Chapter 1. Searching Google 1. Setting Preferences 2. Language Tools 3. Anatomy of a Search Result 4. Specialized Vocabularies: Slang and Terminology 5. Getting Around the 10 Word Limit 6. Word Order Matters 7. Repetition Matters 8. Mixing Syntaxes 9. Hacking Google URLs 10. Hacking Google Search Forms 11. Date-Range Searching 12. Understanding and Using Julian Dates 13. Using Full-Word Wildcards 14. inurl: Versus site: 15. Checking Spelling 16. Consulting the Dictionary 17. Consulting the Phonebook 18. Tracking Stocks 19. Google Interface for Translators 20. Searching Article Archives 21. Finding Directories of Information 22. Finding Technical Definitions 23. Finding Weblog Commentary 24. The Google Toolbar 25. The Mozilla Google Toolbar 26. The Quick Search Toolbar 27. GAPIS 28. Googling with Bookmarklets Chapter 2. Google Special Services and Collections 29. Google Directory 30. Google Groups 31. Google Images 32. Google News 33. Google Catalogs 34. Froogle 35. Google Labs Chapter 3. Third-Party Google Services 36. XooMLe: The Google API in Plain Old XML 37. Google by Email 38. Simplifying Google Groups URLs 39. What Does Google Think Of... 40. GooglePeople Chapter 4. Non-API Google Applications 41. Don't Try This at Home 42. Building a Custom Date-Range Search Form 43. Building Google Directory URLs 44. Scraping Google Results 45. Scraping Google AdWords 46. Scraping Google Groups 47. Scraping Google News 48. Scraping Google Catalogs 49. Scraping the Google Phonebook Chapter 5. Introducing the Google Web API 50. Programming the Google Web API with Perl 51. Looping Around the 10-Result Limit 52.
    [Show full text]
  • Name Description
    Perl version 5.10.0 documentation - perlnewmod NAME perlnewmod - preparing a new module for distribution DESCRIPTION This document gives you some suggestions about how to go about writingPerl modules, preparing them for distribution, and making them availablevia CPAN. One of the things that makes Perl really powerful is the fact that Perlhackers tend to want to share the solutions to problems they've faced,so you and I don't have to battle with the same problem again. The main way they do this is by abstracting the solution into a Perlmodule. If you don't know what one of these is, the rest of thisdocument isn't going to be much use to you. You're also missing out onan awful lot of useful code; consider having a look at perlmod, perlmodlib and perlmodinstall before coming back here. When you've found that there isn't a module available for what you'retrying to do, and you've had to write the code yourself, considerpackaging up the solution into a module and uploading it to CPAN so thatothers can benefit. Warning We're going to primarily concentrate on Perl-only modules here, ratherthan XS modules. XS modules serve a rather different purpose, andyou should consider different things before distributing them - thepopularity of the library you are gluing, the portability to otheroperating systems, and so on. However, the notes on preparing the Perlside of the module and packaging and distributing it will apply equallywell to an XS module as a pure-Perl one. What should I make into a module? You should make a module out of any code that you think is going to beuseful to others.
    [Show full text]
  • Coleman-Coding-Freedom.Pdf
    Coding Freedom !" Coding Freedom THE ETHICS AND AESTHETICS OF HACKING !" E. GABRIELLA COLEMAN PRINCETON UNIVERSITY PRESS PRINCETON AND OXFORD Copyright © 2013 by Princeton University Press Creative Commons Attribution- NonCommercial- NoDerivs CC BY- NC- ND Requests for permission to modify material from this work should be sent to Permissions, Princeton University Press Published by Princeton University Press, 41 William Street, Princeton, New Jersey 08540 In the United Kingdom: Princeton University Press, 6 Oxford Street, Woodstock, Oxfordshire OX20 1TW press.princeton.edu All Rights Reserved At the time of writing of this book, the references to Internet Web sites (URLs) were accurate. Neither the author nor Princeton University Press is responsible for URLs that may have expired or changed since the manuscript was prepared. Library of Congress Cataloging-in-Publication Data Coleman, E. Gabriella, 1973– Coding freedom : the ethics and aesthetics of hacking / E. Gabriella Coleman. p. cm. Includes bibliographical references and index. ISBN 978-0-691-14460-3 (hbk. : alk. paper)—ISBN 978-0-691-14461-0 (pbk. : alk. paper) 1. Computer hackers. 2. Computer programmers. 3. Computer programming—Moral and ethical aspects. 4. Computer programming—Social aspects. 5. Intellectual freedom. I. Title. HD8039.D37C65 2012 174’.90051--dc23 2012031422 British Library Cataloging- in- Publication Data is available This book has been composed in Sabon Printed on acid- free paper. ∞ Printed in the United States of America 1 3 5 7 9 10 8 6 4 2 This book is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE !" We must be free not because we claim freedom, but because we practice it.
    [Show full text]
  • COMS 3101 Programming Languages: Perl Lecture 5
    COMS 3101 Programming Languages: Perl Lecture 5 Fall 2013 Instructor: Ilia Vovsha http://www.cs.columbia.edu/~vovsha/coms3101/perl Lecture Outline Packages & Modules Concepts: Subroutine references SbliSymbolic references Garbage collection Saving structures Objects and Classes Next: More OOP, CPAN 5.2 Remarks Pattern matching “cage” can be any character: • m// or // is equivalent to m{} • s/// is equivalent to s{} {} • // are just customary quote characters for pattern matching behavior. In fact you could choose your own character instead of {} (e.g. m ! !) • Convenient if lots of slhlashes in the pattern ref function: returns type of reference (a string) • $rtype = ref($href); # returns “HASH” • $rtype = ref($aref); # returns “ARRAY” • if ( ref($href) eq “HASH” ) { … } 5.3 Packages & Modules Why do we need them? Package or module, what is the difference? ‘use’ vs. ‘require’ Importing from another package Pragmatic modules (ppgragmas) 5.4 Packages (purpose) sub parse_text { # code from one file … $count = $count++; … } sub normalize { # code from another file $count++; … } # Use both functions: parse_text(); normalize(); print “$count\n”; # Which $count? What is its value? 5.5 Packages (definition) Balanced code: abstraction + reuse Every chkhunk of code has its own namespace. In PlPerl, a namespace is called a package Independent of files: • Multiple packages in one file • Single package spanning multiple files • Most common: one package per file Best approach: one package per file where file name is package name
    [Show full text]
  • Name Introduction Quick Checklist
    Perl version 5.10.0 documentation - perlmodstyle NAME perlmodstyle - Perl module style guide INTRODUCTION This document attempts to describe the Perl Community's "best practice"for writing Perl modules. It extends the recommendations found in perlstyle , which should be considered required readingbefore reading this document. While this document is intended to be useful to all module authors, it isparticularly aimed at authors who wish to publish their modules on CPAN. The focus is on elements of style which are visible to the users of a module, rather than those parts which are only seen by the module's developers. However, many of the guidelines presented in this documentcan be extrapolated and applied successfully to a module's internals. This document differs from perlnewmod in that it is a style guiderather than a tutorial on creating CPAN modules. It provides achecklist against which modules can be compared to determine whether they conform to best practice, without necessarily describing in detailhow to achieve this. All the advice contained in this document has been gleaned fromextensive conversations with experienced CPAN authors and users. Everypiece of advice given here is the result of previous mistakes. Thisinformation is here to help you avoid the same mistakes and the extrawork that would inevitably be required to fix them. The first section of this document provides an itemized checklist; subsequent sections provide a more detailed discussion of the items on the list. The final section, "Common Pitfalls", describes some of the most popular mistakes made by CPAN authors. QUICK CHECKLIST For more detail on each item in this checklist, see below.
    [Show full text]
  • Intrusion Detection Systems for Smart Home Iot Devices: Experimental Comparison Study
    Intrusion Detection Systems for Smart Home IoT Devices: Experimental Comparison Study Faisal Alsakran1, Gueltoum Bendiab1, Stavros Shiaeles2, and Nicholas Kolokotronis3 1 CSCAN, University of Plymouth, PL4 8AA, Plymouth, UK [email protected], [email protected] 2 School of Computing, University of Portsmouth, PO1 2UP, Portsmouth, UK [email protected] 3 Department of Informatics and Telecommunications, University of Peloponnese, 22131 Tripolis, Greece [email protected] ABSTRACT Smart homes are one of the most promising applications of the 1 INTRODUCTION emerging Internet of Things (IoT) technology. With the growing Smart home technology also often referred to as home automation number of IoT related devices such as smart thermostats, smart allows the entire home to be automated and therefore, the connected fridges, smart speaker, smart light bulbs and smart locks, smart smart home devices can be remotely controlled and operated, from any homes promise to make our lives easier and more comfortable. location in the world, through a smartphone app, iPads or other network However, the increased deployment of such smart devices brings an devices [13]. In recent years, smart home technology is gaining increase in potential security risks and home privacy breaches. In tremendous ground at all levels. Economic reports affirm that connected order to overcome such risks, Intrusion Detection Systems are home market becomes the largest IoT segment at seven billion related presented as pertinent tools that can provide network-level smart devices in 2018, which present 26% of the global IoT devices protection for smart devices deployed in home environments. These market [14]. According to Gartner [32] this segment is expected to grow systems monitor the network activities of the smart home-connected to 20.4 billion devices by 2020.
    [Show full text]
  • Perlmonks.Com with a Gaim Plug-In SEEKING WISDOM
    PROGRAMMING Perl: A Gaim Plugin Get the news from perlmonks.com with a Gaim plug-in SEEKING WISDOM irst-time visitors to perlmonks. The Gaim project offers an instant messenger client that speaks a large com are rubbing their eyes in dis- Fbelief: High-caliber Perl hackers number of protocols. We’ll show you how to extend Gaim with Perl are jumping to answer even the simplest of newbie questions. The reason for this plugins. BY MICHAEL SCHILLI is that the community assigns XP (expe- rience) points for the best replies. And the more XP you have, the higher you answer a question correctly typically However, it can take a few seconds to climb in the ranking, from a novice, to a gets the most XP. Instead of pulling the download the content of a remote web monk, and slowly to expert status. web page with the latest questions time page. Both DNS name resolution and the and time again, it makes sense to script process of retrieving the content of the Best of Class the process and have the script let you requested web page can take some time, Due to the community dynamics on know when a new query arrives. during which the CPU should return to perlmonks.com, the The pmwatcher.pl script described other tasks. The tried-and-trusted POE first person to in this issue fetches the perlmonks. [3] framework provides exactly what we com page with the Newest Nodes at need. The POE kernel runs a single pro- regular intervals, remembering cess (and only a single thread), but uses older entries and sending out an cooperative multitasking between con- instant message when it discovers current tasks to ensure that each one is new postings.
    [Show full text]
  • Pragmaticperl-Interviews-A4.Pdf
    Pragmatic Perl Interviews pragmaticperl.com 2013—2015 Editor and interviewer: Viacheslav Tykhanovskyi Covers: Marko Ivanyk Revision: 2018-03-02 11:22 © Pragmatic Perl Contents 1 Preface .......................................... 1 2 Alexis Sukrieh (April 2013) ............................... 2 3 Sawyer X (May 2013) .................................. 10 4 Stevan Little (September 2013) ............................. 17 5 chromatic (October 2013) ................................ 22 6 Marc Lehmann (November 2013) ............................ 29 7 Tokuhiro Matsuno (January 2014) ........................... 46 8 Randal Schwartz (February 2014) ........................... 53 9 Christian Walde (May 2014) .............................. 56 10 Florian Ragwitz (rafl) (June 2014) ........................... 62 11 Curtis “Ovid” Poe (September 2014) .......................... 70 12 Leon Timmermans (October 2014) ........................... 77 13 Olaf Alders (December 2014) .............................. 81 14 Ricardo Signes (January 2015) ............................. 87 15 Neil Bowers (February 2015) .............................. 94 16 Renée Bäcker (June 2015) ................................ 102 17 David Golden (July 2015) ................................ 109 18 Philippe Bruhat (Book) (August 2015) . 115 19 Author .......................................... 123 i Preface 1 Preface Hello there! You have downloaded a compilation of interviews done with Perl pro- grammers in Pragmatic Perl journal from 2013 to 2015. Since the journal itself is in Russian
    [Show full text]
  • Compiling Your Own Perl
    APPENDIX A Compiling Your Own Perl Compiling Perl on a Unix-like system is simple. First, obtain the source for Perl from CPAN (dppl6++_l]j*lanh*knc+on_+NA=@IA*dpih). Then input the following sequence of commands: p]nvtrblanh)1*4*4*p]n*cv _`lanh)1*4*4 od?kjbecqna)`ao i]ga i]gapaop oq`ki]gaejop]hh On most Unix systems, this code will result in your lanh being installed into the +qon+ hk_]h+ directory tree. If you want it installed elsewhere—for example, in the local directory in your home directory—then replace od?kjbecqna)`a with the following: od?kjbecqna)`ao)@lnabet9z+hk_]h+ which should enable you to install Perl on your computer without root access. Note that the )`ao flag uses all the default options for compiling Perl. If you know that you want nonstandard configuration, just use the flag )`a instead to be prompted for your requirements. Be aware that the source for Perl 5.10.0 requires a patch to work properly with Catalyst. This is fixed in subsequent versions of Perl 5.10. If you need to test code guaranteed to run on a wide range of systems, you should con- sider using Perl version 5.8.7. Perl versions greater than 5.8.7 contain features that were not available in earlier versions of Perl, so Perl 5.8.7 is feature complete for all versions of Perl that Catalyst will run on (version 5.8.1 and later). Put another way, versions 5.8.8 and later have new features that you can’t rely on in earlier releases.
    [Show full text]
  • Modern Perl, Fourth Edition
    Prepared exclusively for none ofyourbusiness Prepared exclusively for none ofyourbusiness Early Praise for Modern Perl, Fourth Edition A dozen years ago I was sure I knew what Perl looked like: unreadable and obscure. chromatic showed me beautiful, structured expressive code then. He’s the right guy to teach Modern Perl. He was writing it before it existed. ➤ Daniel Steinberg President, DimSumThinking, Inc. A tour de force of idiomatic code, Modern Perl teaches you not just “how” but also “why.” ➤ David Farrell Editor, PerlTricks.com If I had to pick a single book to teach Perl 5, this is the one I’d choose. As I read it, I was reminded of the first time I read K&R. It will teach everything that one needs to know to write Perl 5 well. ➤ David Golden Member, Perl 5 Porters, Autopragmatic, LLC I’m about to teach a new hire Perl using the first edition of Modern Perl. I’d much rather use the updated copy! ➤ Belden Lyman Principal Software Engineer, MediaMath It’s not the Perl book you deserve. It’s the Perl book you need. ➤ Gizmo Mathboy Co-founder, Greater Lafayette Open Source Symposium (GLOSSY) Prepared exclusively for none ofyourbusiness We've left this page blank to make the page numbers the same in the electronic and paper books. We tried just leaving it out, but then people wrote us to ask about the missing pages. Anyway, Eddy the Gerbil wanted to say “hello.” Prepared exclusively for none ofyourbusiness Modern Perl, Fourth Edition chromatic The Pragmatic Bookshelf Dallas, Texas • Raleigh, North Carolina Prepared exclusively for none ofyourbusiness Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks.
    [Show full text]
  • Writing PERL Packages & Modules
    WWRRIITTIINNGG PPEERRLL MMOODDUULLEESS http://www.tutorialspoint.com/perl/perl_modules.htm Copyright © tutorialspoint.com What are Packages? A package is a collection of code which lives in its own namespace A namespace is a named collection of unique variable names alsocalledasymboltable. Namespaces prevent variable name collisions between packages Packages enable the construction of modules which, when used, won't clobbber variables and functions outside of the modules's own namespace The Package Statement package statement switches the current naming context to a specified namespace symboltable If the named package does not exists, a new namespace is first created. $i = 1; print "$i\n"; # Prints "1" package foo; $i = 2; print "$i\n"; # Prints "2" package main; print "$i\n"; # Prints "1" The package stays in effect until either another package statement is invoked, or until the end of the end of the current block or file. You can explicitly refer to variables within a package using the :: package qualifier $PACKAGE_NAME::VARIABLE_NAME For Example: $i = 1; print "$i\n"; # Prints "1" package foo; $i = 2; print "$i\n"; # Prints "2" package main; print "$i\n"; # Prints "1" print "$foo::i\n"; # Prints "2" BEGIN and END Blocks You may define any number of code blocks named BEGIN and END which act as constructors and destructors respectively. BEGIN { ... } END { ... } BEGIN { ... } END { ... } Every BEGIN block is executed after the perl script is loaded and compiled but before any other statement is executed Every END block is executed just before the perl interpreter exits. The BEGIN and END blocks are particularly useful when creating Perl modules.
    [Show full text]