Learning Perl 6.Pdf

Total Page:16

File Type:pdf, Size:1020Kb

Learning Perl 6.Pdf Learning Perl 6 KEEPING THE EASY, HARD, AND IMPOSSIBLE WITHIN REACH brian d foy www.allitebooks.com www.allitebooks.com Learning Perl 6 Keeping the Easy, Hard, and Impossible Within Reach brian d foy Beijing Boston Farnham Sebastopol Tokyo www.allitebooks.com Learning Perl 6 by brian d foy Copyright © 2018 brian d foy. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com/safari). For more information, contact our corporate/insti‐ tutional sales department: 800-998-9938 or [email protected]. Editor: Jeff Bleiel Indexer: Lucie Haskins Production Editor: Nicholas Adams Interior Designer: David Futato Copyeditor: Rachel Head Cover Designer: Karen Montgomery Proofreader: Kim Cofer Illustrator: Rebecca Demarest September 2018: First Edition Revision History for the First Edition 2018-08-24: First Release See http://oreilly.com/catalog/errata.csp?isbn=9781491977682 for release details. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Learning Perl 6, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc. The views expressed in this work are those of the author, and do not represent the publisher’s views. While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights. 978-1-491-97768-2 [LSI] www.allitebooks.com Table of Contents Preface. xiii 1. Introduction. 1 Why Perl 6? 1 First Steps with the REPL 2 Reading the Documentation 4 Basic Syntax 4 Terms 5 Operators and Expressions 5 Statements 8 Blocks 8 Comments 9 Unspace 10 Objects and Classes 10 Variables 11 Simple Output 13 Lexical Scope 13 Predefined Variables 14 Making and Running a Program 15 Summary 16 2. Number Guessing. 17 Binding and Assignment 17 A MAIN Program 18 Program Arguments 19 Prompting for Values 21 Literal Numbers 22 Formatting Numbers 23 iii www.allitebooks.com Numeric Operations 24 Conditional Execution 27 Boolean Values 27 Comparing Things 30 Conditional Branching 33 Putting It All Together 35 Summary 37 3. Numbers. 39 Number Types 39 Integers 40 Type Constraints 40 Smart Matching 42 Rational Numbers 44 Imaginary and Complex Numbers 46 Numbers Small and Large 48 The Numeric Hierarchy 49 Summary 50 4. Strings. 51 Literal Quoting 51 Escaped Strings 52 Adverbs for Quoting 53 String Operators and Methods 54 Looking Inside Strings 56 Normal Form Grapheme 57 String Comparisons 58 Prompting for Input 59 Number to String Conversions 61 String to Number Conversions 61 Interpolated Strings 63 Here Docs 66 Shell Strings 67 Shell Safety 68 Fancier Quoting 69 Summary 70 5. Building Blocks. 71 Blocks 71 Lexical Scope 72 Control Structures 73 Phasers 75 iv | Table of Contents Storing Blocks 78 Blocks with Parameters 79 Simple Subroutines 82 Named Subroutines 84 Whatever Code 85 Subsets 85 Summary 87 6. Positionals. 89 Constructing a List 89 Iterating All the Elements 92 Ranges 96 The @ Coercer 97 Sequences 98 Infinite Lazy Lists 100 Gathering Values 102 Single-Element Access 103 Changing a Single Element 105 Multiple-Element Access 106 Arrays 106 Constructing an Array 107 Interpolating Arrays 108 Array Operations 109 Lists of Lists 110 Flattening Lists 111 Interesting Sublists 112 Combining Lists 113 The Zip Operator, Z 113 The Cross Operator, X 114 The Hyperoperators 115 The Reduction Operator 116 Filtering Lists 117 Transforming a List 118 Sorting Lists 119 Sorting on Multiple Comparisons 121 Summary 122 7. When Things Go Wrong. 123 Exceptions 123 Catching Exceptions 124 Backtraces 126 Rethrowing Errors 129 Table of Contents | v Throwing Your Own Exceptions 130 Defining Your Own Exception Types 131 Failures 131 Warnings 132 The Wisdom of Exceptions 133 Summary 134 8. Files and Directories, Input and Output. 135 File Paths 135 File Test Operators 137 File Metadata 139 Linking and Unlinking Files 140 Renaming and Copying Files 142 Manipulating Directories 143 Directory Listings 144 Creating Directories 145 Removing Directories 145 Formatted Output 146 Common Formatting Tasks 148 The Standard Filehandles 149 Standard Output 149 Standard Error 150 Standard Input 151 Reading Input 151 Reading Lines 152 Reading a File 153 Writing Output 154 Opening a File for Writing 154 Binary Files 155 Moving Around 156 Writing Binary Files 156 Summary 157 9. Associatives. 159 Pairs 159 Adverbs 160 Modifying a Pair 161 Maps 162 Checking Keys 163 Creating from a Positional 163 Checking Allowed Values 164 Hashes 165 vi | Table of Contents Accumulating with a Hash 167 Multilevel Hashes 169 Summary 170 10. Using Modules. 171 Installing Modules 171 Loading Modules 172 Finding the Module 173 Lexical Effect 175 Loading a Module at Runtime 176 Fetching Data from the Web 179 Running Perl 5 in Perl 6 179 Summary 180 11. Subroutines. 181 A Basic Subroutine 181 Extra Arguments 182 Explicit Returns 182 Recursing 184 Iterating Instead of Recursing 184 Storing Subroutines in Libraries 185 Exporting Subroutines 186 Positional Parameters 187 Slurpy Parameters 188 Have It Both Ways 189 Combining Slurpies 190 Optional and Default Arguments 191 Parameter Traits 191 Parameter Constraints 192 Same Name, Different Signature 193 Literal Value Parameters 193 Number of Arguments 195 Parameter Types 195 Named Parameters 197 Required Named Parameters 198 Named Parameters for Free 198 Mixed Parameters 199 Return Types 199 Summary 201 12. Classes. 203 Your First Class 203 Table of Contents | vii Defining Methods 204 Private Methods 205 Defining Subroutines 206 Objects 206 Private Attributes 207 Public Attributes 209 multi Methods 210 Inheriting Types 212 Checking Inheritance 214 Stub Methods 214 Controlling Object Creation 215 Building Objects 216 Tweaking Objects 219 Private Classes 220 Summary 221 13. Roles. 223 Adding Behavior to Classes 223 Applying Multiple Roles 224 Methods in Roles 225 De-Conflicting Roles 226 Anonymous Roles 229 Summary 231 14. Junctions and Sets. 233 Junctions 233 any 233 all 237 one 237 none 238 Some Junctive Tricks 238 Sets 239 Set Operations 242 Summary 243 15. Regular Expressions. 245 The Match Operator 245 Match Operator Syntax 246 Successful Matches 247 Defining a Pattern 248 Predefined Patterns 249 Matching Nonliteral Characters 250 viii | Table of Contents Matching Any Character 251 Matching Types of Characters 253 User-Defined Character Classes 255 Matching Adverbs 257 Matching Either Case 257 Ignoring Marks 259 Global Matches 259 Things That Use Patterns 260 Substitutions 260 Summary 261 16. Fancier Regular Expressions. 263 Quantifiers 263 Zero or More 264 Greediness 265 Zero or One 265 Minimal and Maximal 266 Controlling Quantifiers 267 Turning Off Backtracking 267 Captures 268 Named Captures 269 A Capture Tree 271 Backreferences 272 Surrounders and Separators 273 Assertions 274 Anchors 275 Conditions 276 Code Assertions 277 Alternations 279 First Match 279 Longest Token Matching 281 Summary 283 17. Grammars. 285 A Simple Grammar 285 Multiple Rules 288 Debugging Grammars 290 Grammar::Tracer 290 Grammar::Debugger 291 A Simple Action Class 291 Creating an Abstract Syntax Tree 292 Ratcheting 294 Table of Contents | ix Parsing JSON 295 Parsing CSV 298 Adjusting the Grammar 300 Using Roles in Grammars 301 Summary 302 18. Supplies, Channels, and Promises. 303 Supplies 303 Multiple Taps 305 Live Supplies 306 Channels 307 Promises 309 Waiting for Promises 310 Waiting for Multiple Promises 311 Managing Your Own Promises 312 Promise Junctions 314 Reactive Programming 315 Reacting in the Background 318 Summary 320 19. Controlling Other Programs. 321 Quick and Easy 321 Quoted Commands 322 Safer Commands 323 Writing to a Proc 324 Procs 325 Asynchronous Control 326 Summary 327 20. Advanced Topics. 329 One-Liners 329 Declarator Block Comments 329 Feed Operators 330 Destructuring Signatures 331 Defining Your Own Operators 331 Perl 5 Patterns 332 Shaped Arrays 332 Typed Containers 332 NativeCall 333 The with Topicalizer 333 21. Conclusion. 335 x | Table of Contents Glossary. 337 A. Exercise Answers. 349 Index. 435 Table of Contents | xi Preface Welcome to the first edition of Learning Perl 6, a book title that sounds similar to oth‐ ers you may have read and I may have written. This one, however, is my first book about the language called “Perl 6.” I know the name is a bit confusing; I’m not in charge of that part. I’m just the book writer. Okay, I can see you’re not satisfied with that. Here’s the short answer you probably want: if you need to learn Perl because someone made that choice for you, you’re probably looking for my other book, Learning Perl, that covers the widely used Perl 5. That’s the stable ol’ workhorse that’s been around virtually forever. This one is about the new language that’s still growing up and isn’t in wide use yet. Here’s the longer answer for those of you who are still reading. You either know that you want Perl 6 or you don’t really care which one you get as long as you learn a new language. The Backstory of Perl 6 At the Perl Conference in 2000, a group of Perl people got together in a hotel confer‐ ence room in Monterey, California.
Recommended publications
  • MANNING Greenwich (74° W
    Object Oriented Perl Object Oriented Perl DAMIAN CONWAY MANNING Greenwich (74° w. long.) For electronic browsing and ordering of this and other Manning books, visit http://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. 32 Lafayette Place Fax: (203) 661-9018 Greenwich, CT 06830 email: [email protected] ©2000 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. Library of Congress Cataloging-in-Publication Data Conway, Damian, 1964- Object oriented Perl / Damian Conway. p. cm. includes bibliographical references. ISBN 1-884777-79-1 (alk. paper) 1. Object-oriented programming (Computer science) 2. Perl (Computer program language) I. Title. QA76.64.C639 1999 005.13'3--dc21 99-27793 CIP Manning Publications Co. Copyeditor: Adrianne Harun 32 Lafayette
    [Show full text]
  • Scala Tutorial
    Scala Tutorial SCALA TUTORIAL Simply Easy Learning by tutorialspoint.com tutorialspoint.com i ABOUT THE TUTORIAL Scala Tutorial Scala is a modern multi-paradigm programming language designed to express common programming patterns in a concise, elegant, and type-safe way. Scala has been created by Martin Odersky and he released the first version in 2003. Scala smoothly integrates features of object-oriented and functional languages. This tutorial gives a great understanding on Scala. Audience This tutorial has been prepared for the beginners to help them understand programming Language Scala in simple and easy steps. After completing this tutorial, you will find yourself at a moderate level of expertise in using Scala from where you can take yourself to next levels. Prerequisites Scala Programming is based on Java, so if you are aware of Java syntax, then it's pretty easy to learn Scala. Further if you do not have expertise in Java but you know any other programming language like C, C++ or Python, then it will also help in grasping Scala concepts very quickly. Copyright & Disclaimer Notice All the content and graphics on this tutorial are the property of tutorialspoint.com. Any content from tutorialspoint.com or this tutorial may not be redistributed or reproduced in any way, shape, or form without the written permission of tutorialspoint.com. Failure to do so is a violation of copyright laws. This tutorial may contain inaccuracies or errors and tutorialspoint provides no guarantee regarding the accuracy of the site or its contents including this tutorial. If you discover that the tutorialspoint.com site or this tutorial content contains some errors, please contact us at [email protected] TUTORIALS POINT Simply Easy Learning Table of Content Scala Tutorial ..........................................................................
    [Show full text]
  • Learning Perl Through Examples Part 2 L1110@BUMC 2/22/2017
    www.perl.org Learning Perl Through Examples Part 2 L1110@BUMC 2/22/2017 Yun Shen, Programmer Analyst [email protected] IS&T Research Computing Services Spring 2017 Tutorial Resource Before we start, please take a note - all the codes and www.perl.org supporting documents are accessible through: • http://rcs.bu.edu/examples/perl/tutorials/ Yun Shen, Programmer Analyst [email protected] IS&T Research Computing Services Spring 2017 Sign In Sheet We prepared sign-in sheet for each one to sign www.perl.org We do this for internal management and quality control So please SIGN IN if you haven’t done so Yun Shen, Programmer Analyst [email protected] IS&T Research Computing Services Spring 2017 Evaluation One last piece of information before we start: www.perl.org • DON’T FORGET TO GO TO: • http://rcs.bu.edu/survey/tutorial_evaluation.html Leave your feedback for this tutorial (both good and bad as long as it is honest are welcome. Thank you) Yun Shen, Programmer Analyst [email protected] IS&T Research Computing Services Spring 2017 Today’s Topic • Basics on creating your code www.perl.org • About Today’s Example • Learn Through Example 1 – fanconi_example_io.pl • Learn Through Example 2 – fanconi_example_str_process.pl • Learn Through Example 3 – fanconi_example_gene_anno.pl • Extra Examples (if time permit) Yun Shen, Programmer Analyst [email protected] IS&T Research Computing Services Spring 2017 www.perl.org Basics on creating your code How to combine specs, tools, modules and knowledge. Yun Shen, Programmer Analyst [email protected] IS&T Research Computing
    [Show full text]
  • 1 Aliasing and Immutability
    Vocabulary: Accessors & Mutators Computer Science and Engineering The Ohio State University Accessor: A method that reads, but never changes, the Aliasing and Immutability (abstract) state of an object Computer Science and Engineering College of Engineering The Ohio State University Concrete representation may change, so long as change is not visible to client eg Lazy initialization Examples: getter methods, toString Lecture 8 Formally: restores “this” Mutator method: A method that may change the (abstract) state of an object Examples: setter methods Formally: updates “this” Constructors not considered mutators A Fixed Epoch Interface A Broken Time Period Class Computer Science and Engineering The Ohio State University Computer Science and Engineering The Ohio State University // Interface cover story goes here public class Period implements FixedEpoch { // Mathematical modeling … private Date start; // constructor private Date end; // requires start date < end date // initializes start and end dates // operations have specifications based on the model public Period(Date start, Date end) { // exercises … this.start = start; this.e nd = e nd; public interface FixedEpoch { } public Date getStart(); public Date getEnd(); } public Date getStart() { return start; } public Date getEnd() { return end; } } Problem: Aliasing A Better Period Class Computer Science and Engineering The Ohio State University Computer Science and Engineering The Ohio State University Assignment in constructor creates an alias public class Period
    [Show full text]
  • Functional Programming Inside OOP?
    Functional Programming inside OOP? It’s possible with Python >>>whoami() Carlos Villavicencio ● Ecuadorian θ ● Currently: Python & TypeScript ● Community leader ● Martial arts: 剣道、居合道 ● Nature photography enthusiast po5i Cayambe Volcano, 2021. >>>why_functional_programming ● Easier and efficient ● Divide and conquer ● Ease debugging ● Makes code simpler and readable ● Also easier to test >>>history() ● Functions were first-class objects from design. ● Users wanted more functional solutions. ● 1994: map, filter, reduce and lambdas were included. ● In Python 2.2, lambdas have access to the outer scope. “Not having the choice streamlines the thought process.” - Guido van Rossum. The fate of reduce() in Python 3000 https://python-history.blogspot.com/2009/04/origins-of-pythons-functional-features.html >>>has_django_fp() https://github.com/django/django/blob/46786b4193e04d398532bbfc3dcf63c03c1793cb/django/forms/formsets.py#L201-L213 https://github.com/django/django/blob/ca9872905559026af82000e46cde6f7dedc897b6/django/forms/formsets.py#L316-L328 Immutability An immutable object is an object whose state cannot be modified after it is created. Booleans, strings, and integers are immutable objects. List and dictionaries are mutable objects. Thread safety >>>immutability def update_list(value: list) -> None: def update_number(value: int) -> None: value += [10] value += 10 >>> foo = [1, 2, 3] >>> foo = 10 >>> id(foo) >>> update_number(foo) 4479599424 >>> foo >>> update_list(foo) 10 >>> foo 樂 [1, 2, 3, 10] >>> id(foo) 4479599424 >>>immutability def update_number(value: int) -> None: print(value, id(value)) value += 10 print(value, id(value)) >>> foo = 10 >>> update_number(foo) 10 4478220880 ڃ 4478221200 20 >>> foo 10 https://medium.com/@meghamohan/mutable-and-immutable-side-of-python-c2145cf72747 Decorators They are functions which modify the functionality of other functions. Higher order functions.
    [Show full text]
  • Enforcing Abstract Immutability
    Enforcing Abstract Immutability by Jonathan Eyolfson A thesis presented to the University of Waterloo in fulfillment of the thesis requirement for the degree of Doctor of Philosophy in Electrical and Computer Engineering Waterloo, Ontario, Canada, 2018 © Jonathan Eyolfson 2018 Examining Committee Membership The following served on the Examining Committee for this thesis. The decision of the Examining Committee is by majority vote. External Examiner Ana Milanova Associate Professor Rensselaer Polytechnic Institute Supervisor Patrick Lam Associate Professor University of Waterloo Internal Member Lin Tan Associate Professor University of Waterloo Internal Member Werner Dietl Assistant Professor University of Waterloo Internal-external Member Gregor Richards Assistant Professor University of Waterloo ii I hereby declare that I am the sole author of this thesis. This is a true copy of the thesis, including any required final revisions, as accepted by my examiners. I understand that my thesis may be made electronically available to the public. iii Abstract Researchers have recently proposed a number of systems for expressing, verifying, and inferring immutability declarations. These systems are often rigid, and do not support “abstract immutability”. An abstractly immutable object is an object o which is immutable from the point of view of any external methods. The C++ programming language is not rigid—it allows developers to express intent by adding immutability declarations to methods. Abstract immutability allows for performance improvements such as caching, even in the presence of writes to object fields. This dissertation presents a system to enforce abstract immutability. First, we explore abstract immutability in real-world systems. We found that developers often incorrectly use abstract immutability, perhaps because no programming language helps developers correctly implement abstract immutability.
    [Show full text]
  • Java Bytecode Manipulation Framework
    Notice About this document The following copyright statements and licenses apply to software components that are distributed with various versions of the OnCommand Performance Manager products. Your product does not necessarily use all the software components referred to below. Where required, source code is published at the following location: ftp://ftp.netapp.com/frm-ntap/opensource/ 215-09632 _A0_ur001 -Copyright 2014 NetApp, Inc. All rights reserved. 1 Notice Copyrights and licenses The following component is subject to the ANTLR License • ANTLR, ANother Tool for Language Recognition - 2.7.6 © Copyright ANTLR / Terence Parr 2009 ANTLR License SOFTWARE RIGHTS ANTLR 1989-2004 Developed by Terence Parr Partially supported by University of San Francisco & jGuru.com We reserve no legal rights to the ANTLR--it is fully in the public domain. An individual or company may do whatever they wish with source code distributed with ANTLR or the code generated by ANTLR, including the incorporation of ANTLR, or its output, into commerical software. We encourage users to develop software with ANTLR. However, we do ask that credit is given to us for developing ANTLR. By "credit", we mean that if you use ANTLR or incorporate any source code into one of your programs (commercial product, research project, or otherwise) that you acknowledge this fact somewhere in the documentation, research report, etc... If you like ANTLR and have developed a nice tool with the output, please mention that you developed it using ANTLR. In addition, we ask that the headers remain intact in our source code. As long as these guidelines are kept, we expect to continue enhancing this system and expect to make other tools available as they are completed.
    [Show full text]
  • Exploring Language Support for Immutability
    Exploring Language Support for Immutability Michael Coblenz∗, Joshua Sunshine∗, Jonathan Aldrich∗, Brad Myers∗, Sam Webery, Forrest Shully May 8, 2016 CMU-ISR-16-106 This is an extended version of a paper that was published at ICSE [11]. Institute for Software Research School of Computer Science Carnegie Mellon University Pittsburgh, PA 15213 ∗School of Computer Science, Carnegie Mellon University, Pittsburgh, PA, USA ySoftware Engineering Institute, Carnegie Mellon University, Pittsburgh, PA, USA This material is supported in part by NSA lablet contract #H98230-14-C-0140, by NSF grant CNS-1423054, and by Contract No. FA8721-05-C-0003 with CMU for the operation of the SEI, a federally funded research and development center sponsored by the US DoD. Any opinions, findings and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect those of any of the sponsors. Keywords: Programming language design, Programming language usability, Immutability, Mutability, Program- mer productivity, Empirical studies of programmers Abstract Programming languages can restrict state change by preventing it entirely (immutability) or by restricting which clients may modify state (read-only restrictions). The benefits of immutability and read-only restrictions in software structures have been long-argued by practicing software engineers, researchers, and programming language designers. However, there are many proposals for language mechanisms for restricting state change, with a remarkable diversity of tech- niques and goals, and there is little empirical data regarding what practicing software engineers want in their tools and what would benefit them. We systematized the large collection of techniques used by programming languages to help programmers prevent undesired changes in state.
    [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]
  • Teach Yourself Perl 5 in 21 Days
    Teach Yourself Perl 5 in 21 days David Till Table of Contents: Introduction ● Who Should Read This Book? ● Special Features of This Book ● Programming Examples ● End-of-Day Q& A and Workshop ● Conventions Used in This Book ● What You'll Learn in 21 Days Week 1 Week at a Glance ● Where You're Going Day 1 Getting Started ● What Is Perl? ● How Do I Find Perl? ❍ Where Do I Get Perl? ❍ Other Places to Get Perl ● A Sample Perl Program ● Running a Perl Program ❍ If Something Goes Wrong ● The First Line of Your Perl Program: How Comments Work ❍ Comments ● Line 2: Statements, Tokens, and <STDIN> ❍ Statements and Tokens ❍ Tokens and White Space ❍ What the Tokens Do: Reading from Standard Input ● Line 3: Writing to Standard Output ❍ Function Invocations and Arguments ● Error Messages ● Interpretive Languages Versus Compiled Languages ● Summary ● Q&A ● Workshop ❍ Quiz ❍ Exercises Day 2 Basic Operators and Control Flow ● Storing in Scalar Variables Assignment ❍ The Definition of a Scalar Variable ❍ Scalar Variable Syntax ❍ Assigning a Value to a Scalar Variable ● Performing Arithmetic ❍ Example of Miles-to-Kilometers Conversion ❍ The chop Library Function ● Expressions ❍ Assignments and Expressions ● Other Perl Operators ● Introduction to Conditional Statements ● The if Statement ❍ The Conditional Expression ❍ The Statement Block ❍ Testing for Equality Using == ❍ Other Comparison Operators ● Two-Way Branching Using if and else ● Multi-Way Branching Using elsif ● Writing Loops Using the while Statement ● Nesting Conditional Statements ● Looping Using
    [Show full text]
  • Perl for Windows NT Administrators
    BY ROBERT MANGOLD Perl for Windows NT Administrators s the author demonstrates, scripting in Perl can save Windows NT administrators time when Aperforming a variety of tasks. this ever happened to you? The phone rings at WHY PERL? HAS your NT support desk. You are the person on duty, and the security enforcement officer tells you that the screen What is Perl? Perl stands for “Practical Extraction and saver should start after 10 minutes of idle time, not 15 minutes. Report Language,” or “Pathologically Eclectic Rubbish You’re faced with the agonizing task of changing the screen Lister”— both definitions are sanctioned by the Perl com- saver start time on the 1,000 Windows NT workstations that munity (seriously!). Perl is a programming language, like C you just deployed. What can you do? or Java. Wait! Before you mutter in disgust and hastily flip to In another scenario, say you are in a meeting with your the next article, bear with me. You may be thinking, “I’m not boss, and he tells you to rename the server that holds the a programmer, nor do not want to be a programmer. I will not roaming profiles. You will need to change the profile path on ‘go gentle into that good night.’” (I could not resist using a roughly 700 user accounts. Your boss asks you how long it quote from Dylan Thomas.) will take to accomplish this task, and you know that you will So, why should you become familiar with Perl? Simple. It have to make the changes after hours, but it’s your son’s second can save you time, win you friends, allow you to have a more birthday party tonight.
    [Show full text]
  • Programming Perl (Nutshell Handbooks) Randal L. Schwartz
    [PDF] Programming Perl (Nutshell Handbooks) Randal L. Schwartz, Larry Wall - pdf download free book Programming Perl (Nutshell Handbooks) PDF, Programming Perl (Nutshell Handbooks) Download PDF, Programming Perl (Nutshell Handbooks) by Randal L. Schwartz, Larry Wall Download, Programming Perl (Nutshell Handbooks) Full Collection, Read Best Book Online Programming Perl (Nutshell Handbooks), Read Online Programming Perl (Nutshell Handbooks) Ebook Popular, Download Free Programming Perl (Nutshell Handbooks) Book, Download PDF Programming Perl (Nutshell Handbooks), pdf free download Programming Perl (Nutshell Handbooks), by Randal L. Schwartz, Larry Wall Programming Perl (Nutshell Handbooks), the book Programming Perl (Nutshell Handbooks), Download Programming Perl (Nutshell Handbooks) Online Free, Read Online Programming Perl (Nutshell Handbooks) Book, Read Programming Perl (Nutshell Handbooks) Full Collection, Programming Perl (Nutshell Handbooks) PDF read online, Programming Perl (Nutshell Handbooks) Ebooks, Programming Perl (Nutshell Handbooks) Free Download, Programming Perl (Nutshell Handbooks) Free PDF Download, Programming Perl (Nutshell Handbooks) Books Online, PDF Download Programming Perl (Nutshell Handbooks) Free Collection, CLICK HERE FOR DOWNLOAD pdf, mobi, epub, azw, kindle Description: About the Author Randal L. Schwartz is a two-decade veteran of the software industry. He is skilled in software design, system administration, security, technical writing, and training. Randal has coauthored the "must-have" standards: Programming Perl, Learning Perl, Learning Perl for Win32 Systems, and Effective Perl Learning, and is a regular columnist for WebTechniques, PerformanceComputing, SysAdmin, and Linux magazines. He is also a frequent contributor to the Perl newsgroups, and has moderated comp.lang.perl.announce since its inception. His offbeat humor and technical mastery have reached legendary proportions worldwide (but he probably started some of those legends himself).
    [Show full text]