CSCI-GA.3033.003 Scripting Languages Anonymous Functions

Total Page:16

File Type:pdf, Size:1020Kb

CSCI-GA.3033.003 Scripting Languages Anonymous Functions • CSCI-GA.3033-003 NYU • 6/14/2012 Context, Modules, Glue (Perl) Anonymous functions • Function definition can omit name sub [id] [proto] [attrs] [{…}] CSCI-GA.3033.003 Higher-order function: • Example script: has function param or #!/usr/bin/env perl returns function result Scripting Languages use warnings; use strict; sub callFn { my ($fn, $x) = @_; &$fn($x); } 6/14/2012 sub printIt { my ($it) = @_; print "printIt $it\n”; } #pass reference to named subroutine; prints "printIt Hello" callFn(\&printIt, "Hello"); Context and Modules (Perl) #pass reference to anonymous subroutine; prints "lambda Hi" Scripting as Glue callFn(sub { my ($it) = @_; print "lambda $it\n" }, "Hi"); • Useful for call-backs, e.g., sort/compare © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 1 © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 2 Perl Outline Idiomatic Perl • Regular expressions (continued) • Interpreter specification: #! • Type conversions • Regular expressions extract data • Programming in the large – Captured groups: $1, $2, … • Hashes and arrays store data • Scripting as glue – Nested references build up data structures • Default operand: $_ • Parameter array: @_ • String interpolations report results © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 3 © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 4 Perl Soap-box Example from 5/24/2012, Revisited Readable Perl #!/usr/bin/perl -w %cup2g = ( flour => 110, sugar => 225, butter => 225 ); %volume = ( cup => 1, tbsp => 16, tsp => 48, ml => 236 ); • Use pragmata: warnings, strict, %weight = ( lb => 1, oz => 16, g => 453 ); while (<>) { maybe also diagnostics, sigtrap my ($qty, $unit, $ing) = /([0-9.]+) (\w+) (\w+)/; if ($cup2g{$ing} && $volume{$unit}) { • Avoid default $_ $qty = 1.0 * $qty * $cup2g{$ing} / $volume{$unit}; $unit = 'g'; • Name your subroutine parameters } elsif ($volume{$unit}) { $qty = 1.0 * $qty * $volume{ml} / $volume{$unit}; • Use my, avoid local $unit = 'ml'; } elsif ($weight{$unit}) { • Use /x modifier on regular expressions $qty = 1.0 * $qty * $weight{g} / $weight{$unit}; $unit = 'g'; – Add whitespace, line breaks, comments } printf("%d $unit $ing\n", $qty + .5); • Use modules for large projects } © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 5 © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 6 • © Martin Hirzel • 1 • CSCI-GA.3033-003 NYU • 6/14/2012 Context, Modules, Glue (Perl) Concepts Perl Inside a Regular Expression Chomsky Hierarchy Kind Construct Syntax Example Pattern Matches Type Languages Automata Rules Essentials Character Itself b b 0 Recursively Turing machine α→β Concatenation e e bc bc enumerable 1 2 Alternative (or) e1|e2 a|bc a, bc 1 Context Linear bounded B α γ→αδγ Repetition (≥0) e* a* , a, aa, aaa sensitive Turing machine Grouping (e) (a|b)c ac, bc 2 Context free Pushdown A→β Quantifier Optional e? (a|b)? , a, b automaton (BNF) Repetition (≥1) e+ a+ a, aa, aaa 3 Regular Finite state A→b, C→dE Repetition e{n} a{3} aaa machine (regexp) Char class Custom class […] [a-c] a, b, c Wildcard character , , • Formal regexp only has “essentials” . a 3 : Shortcut class \… \d 0,1,2,…,9 • Perl adds shortcuts and non-regular features Assertion Zero-width anchor $,^,\b,… \b (word boundary) © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 7 © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 8 Perl Perl Non-Regular Perl Regex Features Non-Regular Perl Regex Examples • Non-regular = not essential feature, and can not be emulated by essential features Description Regex Matched – Backtracking engine, may take exponential time Square (\d+)x\1 123x123 • Backreferences in same pattern: \1, \2, … (repeated) • Zero-width assertions: Palindrome (\w+)\w(??{reverse $1}) redivider – Look-ahead positive (?=…), negative (?!…) (mirrored) – Look-behind positive (?<=…), negative (?<!…) Balanced (<+)x(??{'>' x length $1}) <<<x>>> • Match-time code execution: (?{…}) parentheses • Match-time interpolation: (??{…}) • Backtracking suppression: (?>…) © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 9 © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 10 Concepts Outline Natural and Artificial Languages English Perl • Regular expressions (continued) Concept Examples Feature Examples • Type conversions Noun fish Variable $line Pronoun it, they Default variable $_, @_ • Programming in the large Inflection …s Sigil @… • Scripting as glue Singular apple Scalar $i Plural oranges Array @row Verb cook Function sort Irregular verb read Operator <…> Infinitive to be Function reference &cmp Context go fish Context if(@a)… © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 11 © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 12 • © Martin Hirzel • 2 • CSCI-GA.3033-003 NYU • 6/14/2012 Context, Modules, Glue (Perl) Perl Perl Context Primitive Conversions • When you use a value in a different context Value Context than the value’s type, Perl converts it Boolean Number String Reference – E.g., using array as scalar -> int length 0 false "" undefined Number identity • Context provided by: !=0 true "value" – Operator: e.g., string . string "" false 0 symbolic – Function: e.g., list identity print String "0" false 0 reference – Assignment: e.g., @a = list Other true prefix – Statement: e.g., if (boolean) {…} Undefined false 0 "" undefined • Functions provide context for parameters, and can react to context for return value Reference true addr "typ(adr)" identity © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 13 © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 14 Perl Concepts List Conversions Weak/Strong, Static/Dynamic Typing Value Context Strong typing Scalar List (explicit conversions) ML Scalar identity 1-element list Scheme Java List literal last element flattened sublists VBA Array length identity PHP empty "0" empty list Hash JavaScript non-empty "size/buckets" k , v , k , v ,… C 1 1 2 2 Perl true iff match all groups m// Weak typing end of file "" empty array (implicit conversions) assembler <…> not EOF line all lines Static typing Dynamic typing (compile-time checks) (runtime checks) © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 15 © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 16 Perl Perl Functions and Context Prototype Example • Prototype provides context for parameters • Example from page 227 of “Programming Perl”, 3rd ed. Wall, Christiansen, Orwant. O’Reilly, 2000. – sub [id] [proto] [attrs] [{…}] • See also the Error module on CPAN. – No prototype: list operator Function definitions Example usage – proto = (protoChar*) sub try(&$) { try { scalar, list, hash, file handle – $ @ % * my ($try, $catch) = @_; die "phooey"; – & subroutine (in first slot: bare block, no comma) eval { &$try }; } #not end of the call! – ; separates mandatory from optional arguments if ($@) { catch { – \ adds backslashes on actuals local $_ = $@; /phooey/ and &$catch; print "unphooey\n"; checks context for return value • wantarray } }; – true = list, false = array, undefined = void context } sub catch (&) { $_[0] } © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 17 © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 18 • © Martin Hirzel • 3 • CSCI-GA.3033-003 NYU • 6/14/2012 Context, Modules, Glue (Perl) Perl Outline Modules • Module = file p/q.pm that starts with • Regular expressions (continued) declaration package p::q • Type conversions – Group library functions for reuse • Programming in the large – E.g., Math::BigInt, arbitrary precision arithmetic • Module import: access with unqualified names • Scripting as glue – Compile-time use p; runtime require p; – Disable locally: no p; • Pragma = pragmatic module – Changes Perl behavior in fundamental way – E.g., strict, forces variable declarations © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 19 © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 20 Perl Concepts Module Example Pluggable Type Systems use strict; use warnings; # put this code in a package apple; # file apple.pm sub create { • User chooses between multiple alternative my ($weight, $color) = @_; return { WEIGHT => $weight, COLOR => $color }; optional type systems, e.g., in Perl: } no implicit declarations sub pluck { – use strict "vars"; my $ref_to_hash = $_[0]; – use strict "refs"; no string→ref conversion return $ref_to_hash->{COLOR} . " apple"; } – use strict "subs"; no bareword strings sub prepare { my ($ref_to_hash, $how) = @_; – use warnings; same as perl -w return $how . "d " . pluck($ref_to_hash); – perl -T taint-flow checking } 1 # return true = success • Motivation: trade-off between ease of writing, #!/usr/bin/perl use strict; use warnings; use apple; # note the "use apple" maintainability, robustness, and security our $fruit = apple::create(150, "red"); # from a different file print apple::prepare($fruit, "slice"), "\n"; # "sliced red apple" – Similar to “Option Explicit” in VBA © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 21 © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 22 Perl Perl Structure of a Perl Application Using Objects Compilation unit Usually, file; also, -e, eval arg #!/usr/bin/perl Import class module Package Named global namespace use strict; use warnings; use Apple; may vary by block; usually: one per file our $a1 = new Apple(150, "green"); Constructor call forms our $a2 = Apple->new(150, "green"); (indirect obj vs. arrow) Module p/q.pm file with package p::q $a2->{COLOR} = "red"; Set hash entry Pragma Module that changes language print $a1->prepare("slice"), "\n"; Method call Class Package used to bless reference print $a2->prepare("squeeze"), "\n"; (arrow form) Subroutine Named subroutines don’t nest Statements In subroutine or directly in file © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 23 © Martin Hirzel CSCI-GA.3033.003 NYU 6/12/12 24 • © Martin Hirzel • 4 • CSCI-GA.3033-003 NYU • 6/14/2012 Context, Modules, Glue (Perl) Concepts Perl Classes and Objects Defining Classes use strict; use warnings; package Fruit; sub new { Fruit class = package used my ($cls, $weight) = @_; return bless({ WEIGHT => $weight }, $cls); WEIGHT to bless references instance name : blessing package } sub pluck { new() my $self = $_[0]; name $a1 : Apple return "fruit(" . $self->{WEIGHT} . "g)"; pluck() Apple } prepare() WEIGHT = 150 sub prepare { WEIGHT my ($self, $how) = @_; COLOR = “green” return $how .
Recommended publications
  • "This Book Was a Joy to Read. It Covered All Sorts of Techniques for Debugging, Including 'Defensive' Paradigms That Will Eliminate Bugs in the First Place
    Perl Debugged By Peter Scott, Ed Wright Publisher : Addison Wesley Pub Date : March 01, 2001 ISBN : 0-201-70054-9 Table of • Pages : 288 Contents "This book was a joy to read. It covered all sorts of techniques for debugging, including 'defensive' paradigms that will eliminate bugs in the first place. As coach of the USA Programming Team, I find the most difficult thing to teach is debugging. This is the first text I've even heard of that attacks the problem. It does a fine job. Please encourage these guys to write more." -Rob Kolstad Perl Debugged provides the expertise and solutions developers require for coding better, faster, and more reliably in Perl. Focusing on debugging, the most vexing aspect of programming in Perl, this example-rich reference and how-to guide minimizes development, troubleshooting, and maintenance time resulting in the creation of elegant and error-free Perl code. Designed for the novice to intermediate software developer, Perl Debugged will save the programmer time and frustration in debugging Perl programs. Based on the authors' extensive experience with the language, this book guides developers through the entire programming process, tackling the benefits, plights, and pitfalls of Perl programming. Beginning with a guided tour of the Perl documentation, the book progresses to debugging, testing, and performance issues, and also devotes a chapter to CGI programming in Perl. Throughout the book, the authors espouse defensible paradigms for improving the accuracy and performance of Perl code. In addition, Perl Debugged includes Scott and Wright's "Perls of Wisdom" which summarize key ideas from each of the chapters, and an appendix containing a comprehensive listing of Perl debugger commands.
    [Show full text]
  • Software Studies: a Lexicon, Edited by Matthew Fuller, 2008
    fuller_jkt.qxd 4/11/08 7:13 AM Page 1 ••••••••••••••••••••••••••••••••••••• •••• •••••••••••••••••••••••••••••••••• S •••••••••••••••••••••••••••••••••••••new media/cultural studies ••••software studies •••••••••••••••••••••••••••••••••• ••••••••••••••••••••••••••••••••••••• •••• •••••••••••••••••••••••••••••••••• O ••••••••••••••••••••••••••••••••••••• •••• •••••••••••••••••••••••••••••••••• ••••••••••••••••••••••••••••••••••••• •••• •••••••••••••••••••••••••••••••••• F software studies\ a lexicon ••••••••••••••••••••••••••••••••••••• •••• •••••••••••••••••••••••••••••••••• ••••••••••••••••••••••••••••••••••••• •••• •••••••••••••••••••••••••••••••••• T edited by matthew fuller Matthew Fuller is David Gee Reader in ••••••••••••••••••••••••••••••••••••• •••• •••••••••••••••••••••••••••••••••• This collection of short expository, critical, Digital Media at the Centre for Cultural ••••••••••••••••••••••••••••••••••••• •••• •••••••••••••••••••••••••••••••••• W and speculative texts offers a field guide Studies, Goldsmiths College, University of to the cultural, political, social, and aes- London. He is the author of Media ••••••••••••••••••••••••••••••••••••• •••• •••••••••••••••••••••••••••••••••• thetic impact of software. Computing and Ecologies: Materialist Energies in Art and A digital media are essential to the way we Technoculture (MIT Press, 2005) and ••••••••••••••••••••••••••••••••••••• •••• •••••••••••••••••••••••••••••••••• work and live, and much has been said Behind the Blip: Essays on the Culture of •••••••••••••••••••••••••••••••••••••
    [Show full text]
  • Introduction to Perl
    Introduction to Perl #!/usr/bin/perl −w # find−a−func use strict; $_=’$;="per l";map{map {s}^\s+}} ;$_{$_}++unless(/[^a− z]/)}split(/ [\s,]+/)i f(/alpha. *$;/i../w ait/)}‘$; doc\040$; toc‘;;;@[=k eys%_;$; =20;$:=15;;for(0..($;*$:−1 )){$;[$_]="_" ;}until($%++>3*$;||@]>2*$:−3){@_=split(//,splice(@[,rand( @[),1));if(3>@_){next;}$~=int(rand($;));$^=int(rand($:)); $−=$~+$^*$;;my$Erudil=0;{if($Erudil++>2*$:){next;}$a=(−1, 0,1)[rand(3)];$b=(−1,0,1)[rand(3)];unless(($a||$b)&&$~ +$a*@_<=$;&&$~+$a*@_>=0&&$^+$b*@_<=$:&&$^+$b*@_>=0){re do;;}my$llama=0;;for(0..$#_){unless($;[$−+$a*$_+$b* $;*$_]eq$_[$_]||$;[$−+$a*$_+$b*$;*$_]eq"_"){$llam a++;last;}}if($llama){redo;}push@],join("",@_);f or(0..$#_){$;[$−+$a*$_+$b*$;*$_]=$_[$_];}}}@_ =sort@];unshift@_ ,"Find:","−"x5;for$a(0. .$:−1){for$b(0. .$;−1){$~=("a".."z") [rand(26)];$_ ="$;[$a*$;+$b]". $";s;_;$~; ;print;}$_=s hift@_|| $";;print$ ",$", $_,$ /;$_ =shi ft@_ ||$ ";pr int $"x $;, $"x $;, $", $", $_ ,$/;; ;}’ ;;; s[\s+] $$g; eval; Kirrily Robert Paul Fenwick Jacinta Richardson Introduction to Perl by Kirrily Robert, Paul Fenwick, and Jacinta Richardson Copyright © 1999-2000 Netizen Pty Ltd Copyright © 2000 Kirrily Robert Copyright © 2001 Obsidian Consulting Group Pty Ltd Copyright © 2001-2005 Paul Fenwick ([email protected]) Copyright © 2001-2005 Jacinta Richardson ([email protected]) Copyright © 2001-2005 Perl Training Australia Open Publications License 1.0 Cover artwork Copyright (c) 2000 by Stephen B. Jenkins. Used with permission. The use of a llama image with the topic of Perl is a trademark of O’Reilly & Associates, Inc.
    [Show full text]
  • System Logging and Log Analysis
    System Logging and Log Analysis (AKA: Everything we know and hate about system logging) Marcus J. Ranum <[email protected]> 1 Welcome to my system logging and analysis tutorial!!! What we’re covering is a huge topic that touches on security, system administration, and data management. It’s a complex problem and it seems as if everyone has come up with their own approach to dealing with it. In this tutorial, we’ll cover a lot of concepts and tools for deploying them. In order to make this tutorial as useful as possible, don’t hesitate to ask questions at any time. Don’t hesitate to contact me in the future, if you have questions or need advice; just let me know you were at my tutorial and I’ll help you if I can! 1 2 This is one of the better “months” from my 2004 Sourcefire Security Calendar. You can see the entire calendar on: http://www.ranum.com/security/computer_security/calendar/index.html A lot of organizations are spending a ton of perfectly good money on intrusion detection systems and whatnot, but they don’t ever look at their firewall logs. If you think about it for a second, you’ll realize how absolutely backward that is!!System logs represent a terrific source of security data straight “from the horse’s mouth” - or from your devices, anyhow. 2 Philosophy Logs are just data... Processed and analyzed, they become information Put another way... If a tree falls on your network and it shows up in your syslog and nobody is reading it - you’re still squished 3 In military circles, the phrase “actionable intelligence” is an important term used to describe intelligence that has immediate practical importance.
    [Show full text]
  • Mastering Perl, 2Nd Edition.Pdf
    SECOND EDITION Mastering Perl brian d foy Mastering Perl, Second Edition by brian d foy Copyright © 2014 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://my.safaribooksonline.com). For more information, contact our corporate/ institutional sales department: 800-998-9938 or [email protected]. Editor: Rachel Roumeliotis Indexer: Lucie Haskins Production Editor: Kara Ebrahim Cover Designer: Randy Comer Copyeditor: Becca Freed Interior Designer: David Futato Proofreader: Charles Roumeliotis Illustrator: Rebecca Demarest January 2014: Second Edition Revision History for the Second Edition: 2014-01-08: First release See http://oreilly.com/catalog/errata.csp?isbn=9781449393113 for release details. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Mastering Perl, Second Edition, the image of a vicuña and her young, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trade‐ mark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
    [Show full text]
  • Randal L. Schwartz
    Half my life with Perl Randal L. Schwartz Monday, February 17, 14 1 My half-life with Perl Randal L. Schwartz Monday, February 17, 14 2 Who is this guy? . Jack of all trades—master of some . Programmer, writer, trainer, sysadmin, QA, networking, devops, podcaster, comedian... And thinner! Monday, February 17, 14 3 Intertwined . Perl culture . Stonehenge culture . Randal culture . A lot has happened . My memory isn’t as good as it once was . Consider this presentation “a work of fiction” . ... “inspired by actual events” . If you disagree with my “facts” - ... Call for Presentations for OSCON 2014 will probably be in January :) - ... then you can give your own damn talk . Thanks to Elaine and other contributors for the Perl History timeline Monday, February 17, 14 4 Bill Harp . Integral part of “Randal Culture” for nearly 30 years . As such, influenced Stonehenge, and thus Perl . Friend, business partner, marketing director, production assistant, wingman . Sadly, passed away. Bill Harp, 23 Nov 1967 to 22 Feb 2013 . I will miss him, and remember him until my final days Monday, February 17, 14 5 The child me: I like programming. I hate writing. Chose programming as a career at age 9 - Wrote code for PDP-8 FOCAL language “on paper” . Got access to HP2000 Time Shared BASIC via ASR-33 (uppercase!) at age 10 . Many hours of self-taught time with that terminal through the end of high school - Took over teaching BASIC from the “computer” teacher many times - Built an IMSAI 8080 for the school . Flunked middle-school English . Took Journalism in high school (for 3 years!) to avoid any real English exposure - Earned points for typing and page layout, not writing - Only serious story: “Randal assembles an IMSAI 8080 for the school” - As chief editor, I put it front and center on page one Monday, February 17, 14 6 Derailed to an unexpectedly good outcome .
    [Show full text]
  • O'reilly Media Author=Brian D Foy I Can Parse This File and Get the Values from the Different Sections: #!/Usr/Bin/Perl # Config-Ini.Pl
    Mastering Perl ,roadmap.15584 Page ii Monday, July 2, 2007 3:50 PM Other Perl resources from O’Reilly Related titles Advanced Perl Programming Perl CD Bookshelf Intermediate Perl Perl Testing: A Developer’s ™ Learning Perl Notebook Perl Best Practices Programming Perl Hacks Series Home hacks.oreilly.com is a community site for developers and power users of all stripes. Readers learn from each other as they share their favorite tips and tools for Mac OS X, Linux, Google, Windows XP, and more. Perl Books perl.oreilly.com is a complete catalog of O’Reilly’s books on Perl Resource Center and related technologies, including sample chapters and code examples. Perl.com is the central web site for the Perl community. It is the perfect starting place for finding out everything there is to know about Perl. Conferences O’Reilly brings diverse innovators together to nurture the ideas that spark revolutionary industries. We specialize in docu- menting the latest tools and systems, translating the innovator’s knowledge into useful skills for those in the trenches. Visit conferences.oreilly.com for our upcoming events. Safari Bookshelf (safari.oreilly.com) is the premier online refer- ence library for programmers and IT professionals. Conduct searches across more than 1,000 books. Subscribers can zero in on answers to time-critical questions in a matter of seconds. Read the books on your Bookshelf from cover to cover or sim- ply flip to the page you need. Try it today for free. Mastering Perl brian d foy foreword by Randal L. Schwartz Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo Mastering Perl by brian d foy Copyright © 2007 O’Reilly Media, Inc.
    [Show full text]
  • Advanced Perl Programming
    ;-_=_Scrolldown to the Underground_=_-; Advanced Perl Programming http://kickme.to/tiger/ By Sriram Srinivasan; ISBN 1-56592-220-4, 434 pages. First Edition, August 1997. (See the catalog page for this book.) Search the text of Advanced Perl Programming. Index Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z Table of Contents Preface Chapter 1: Data References and Anonymous Storage Chapter 2: Implementing Complex Data Structures Chapter 3: Typeglobs and Symbol Tables Chapter 4: Subroutine References and Closures Chapter 5: Eval Chapter 6: Modules Chapter 7: Object-Oriented Programming Chapter 8: Object Orientation: The Next Few Steps Chapter 9: Tie Chapter 10: Persistence Chapter 11: Implementing Object Persistence Chapter 12: Networking with Sockets Chapter 13: Networking: Implementing RPC Chapter 14: User Interfaces with Tk Chapter 15: GUI Example: Tetris Chapter 16: GUI Example: Man Page Viewer Chapter 17: Template-Driven Code Generation Chapter 18: Extending Perl:A First Course Chapter 19: Embedding Perl:The Easy Way Chapter 20: Perl Internals Appendix A: Tk Widget Reference Appendix B: Syntax Summary Examples The Perl CD Bookshelf Navigation Copyright © 1999 O'Reilly & Associates. All Rights Reserved. Preface Next: Why Perl? Preface Contents: The Case for Scripting Why Perl? What Must I Know? The Book's Approach Conventions Resources Perl Resources We'd Like to Hear from You Acknowledgments Errors, like straws, upon the surface flow; He who would search for pearls must dive below. - John Dryden, All for Love, Prologue This book has two goals: to make you a Perl expert, and, at a broader level, to supplement your current arsenal of techniques and tools for crafting applications.
    [Show full text]
  • Brochure to Find the Sessions That Meet Your Interests, Or Check out Pp
    April 10–15, 2005 Marriott Anaheim Anaheim, CA Join our community of programmers, developers, and systems professionals in sharing solutions and fresh ideas on topics including Linux, clusters, security, open source, system administration, and more. April 10–15, 2005 KEYNOTE ADDRESS by George Dyson, historian and author of Darwin Among the Machines Design Your Own Conference: Combine Tutorials, Invited Talks, Refereed Papers, and Guru Sessions to customize the conference just for you! 5-Day Training Program 3-Day Technical Program Choose one subject or mix and Evening events include: April 10–14 April 13–15, 4 Tracks match to meet your needs. • Poster and Demo Sessions • Now with half-day tutorials • General Session Themes include: • Birds-of-a-Feather Sessions • More than 35 to choose from Refereed Papers • Coding • Vendor BoFs • Learn from industry experts • FREENIX/Open Source • Networking • Receptions • Over 15 new tutorials Refereed Papers • Open Source • Invited Talks • Security • Guru Is In Sessions • Sys Admin Register by March 21 and save up to $300 • www.usenix.org/anaheim05 CONFERENCE AT A GLANCE Sunday, April 10, 2005 7:30 a.m.–5:00 p.m. ON-SITE REGISTRATION 9:00 a.m.–5:00 p.m. TRAINING PROGRAM 6:00 p.m.–7:00 p.m. WELCOME RECEPTION 6:30 p.m.–7:00 p.m. CONFERENCE ORIENTATION Monday, April 11, 2005 7:30 a.m.–5:00 p.m. ON-SITE REGISTRATION 9:00 a.m.–5:00 p.m. TRAINING PROGRAM 8:30 p.m.–11:30 p.m. BIRDS-OF-A-FEATHER SESSIONS CONTENTS INVITATION FROM THE PROGRAM CHAIRS 1 Tuesday, April 12, 2005 7:30 a.m.–5:00 p.m.
    [Show full text]
  • Learning Perl.Pdf
    ;-_=_Scrolldown to the Underground_=_-; Learning Perl http://kickme.to/tiger/ By Randal Schwartz, Tom Christiansen & Larry Wall; ISBN 1-56592-284-0, 302 pages. Second Edition, July 1997. (See the catalog page for this book.) Search the text of Learning Perl. Index Symbols | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X Table of Contents Foreword Preface Chapter 1: Introduction Chapter 2: Scalar Data Chapter 3: Arrays and List Data Chapter 4: Control Structures Chapter 5: Hashes Chapter 6: Basic I/O Chapter 7: Regular Expressions Chapter 8: Functions Chapter 9: Miscellaneous Control Structures Chapter 10: Filehandles and File Tests Chapter 11: Formats Chapter 12: Directory Access Chapter 13: File and Directory Manipulation Chapter 14: Process Management Chapter 15: Other Data Transformation Chapter 16: System Database Access Chapter 17: User Database Manipulation Chapter 18: Converting Other Languages to Perl Chapter 19: CGI Programming Appendix A: Exercise Answers Appendix B: Libraries and Modules Appendix C: Networking Clients Appendix D: Topics We Didn't Mention Examples The Perl CD Bookshelf Navigation Copyright © 1999 O'Reilly & Associates. All Rights Reserved. Foreword Next: Preface Foreword Contents: Second Edition Update Attention, class! Attention! Thank you. Greetings, aspiring magicians. I hope your summer vacations were enjoyable, if too short. Allow me to be the first to welcome you to the College of Wizardry and, more particularly, to this introductory class in the Magic of Perl. I am not your regular instructor, but Professor Schwartz was unavoidably delayed, and has asked me, as the creator of Perl, to step in today and give a few introductory remarks.
    [Show full text]
  • Programming Perl
    Programming Perl #!/usr/bin/perl −w use strict; $_=’ev al("seek\040D ATA,0, 0;");foreach(1..2) {<DATA>;}my @camel1hump;my$camel; my$Camel ;while( <DATA>){$_=sprintf("%−6 9s",$_);my@dromedary 1=split(//);if(defined($ _=<DATA>)){@camel1hum p=split(//);}while(@dromeda ry1){my$camel1hump=0 ;my$CAMEL=3;if(defined($_=shif t(@dromedary1 ))&&/\S/){$camel1hump+=1<<$CAMEL;} $CAMEL−−;if(d efined($_=shift(@dromedary1))&&/\S/){ $camel1hump+=1 <<$CAMEL;}$CAMEL−−;if(defined($_=shift( @camel1hump))&&/\S/){$camel1hump+=1<<$CAMEL;}$CAMEL−−;if( defined($_=shift(@camel1hump))&&/\S/){$camel1hump+=1<<$CAME L;;}$camel.=(split(//,"\040..m‘{/J\047\134}L^7FX"))[$camel1h ump];}$camel.="\n";}@camel1hump=split(/\n/,$camel);foreach(@ camel1hump){chomp;$Camel=$_;tr/LJF7\173\175‘\047/\061\062\063 45678/;tr/12345678/JL7F\175\173\047‘/;$_=reverse;print"$_\040 $Camel\n";}foreach(@camel1hump){chomp;$Camel=$_;y/LJF7\173\17 5‘\047/12345678/;tr/12345678/JL7F\175\173\047‘/;$_=reverse;p rint"\040$_$Camel\n";}#japh−Erudil’;;s;\s*;;g;;eval; eval ("seek\040DATA,0,0;");undef$/;$_=<DATA>;s$\s*$$g;( );;s ;^.*_;;;map{eval"print\"$_\"";}/.{4}/g; __DATA__ \124 \1 50\145\040\165\163\145\040\157\1 46\040\1 41\0 40\143\141 \155\145\1 54\040\1 51\155\ 141 \147\145\0 40\151\156 \040\141 \163\16 3\ 157\143\ 151\141\16 4\151\1 57\156 \040\167 \151\164\1 50\040\ 120\1 45\162\ 154\040\15 1\163\ 040\14 1\040\1 64\162\1 41\144 \145\ 155\14 1\162\ 153\04 0\157 \146\ 040\11 7\047\ 122\1 45\15 1\154\1 54\171 \040 \046\ 012\101\16 3\16 3\15 7\143\15 1\14 1\16 4\145\163 \054 \040 \111\156\14 3\056 \040\
    [Show full text]
  • The Timeline of Perl and Its Culture V3.0 0505
    PerlTimeline The Timeline of Perl and its Culture v3.0_0505 [ 1960s ] [ 1970s ] [ 1980s ] [ 1990s ] [ 2000s ] [ Other URLs of Interest ][ Sources ] This document lives at http://history.perl.org/. If you see any errors, omissions, have comments or would like to contribute a tidbit for this ongoing mission, email [email protected]. Copyright It's the Magic that counts. -- Larry Wall on Perl's apparent ugliness 1960s 1960 Ted Nelson invents hypertext, known as the Project Xanadu. (Fast forward to 1999.) 1964 The concept of pipes connecting processes is suggested by Doug McIlroy at Bell Labs. See http://cm.bell- labs.com/cm/cs/who/dmr/mdmpipe.html. In Perl the same concept is seen in the default variable $_. 1968 Bolt Beranek and Newman, Inc. (BBN) awarded Packet Switch contract to build Interface Message Processors (IMPs). [HIT] US Senator Edward Kennedy sends a congratulatory telegram to BBN for its million-dollar ARPA contract to build the "Interfaith" Message Processor, and thanking them for their ecumenical efforts. [HIT] Douglas Engelbart invents the mouse while working at Xerox PARC. 1969 Unix is like a toll road on which you have to stop every 50 feet to pay another nickel. http://history.perl.org/PerlTimeline.html (1 of 39) [5/5/2001 5:11:28 PM] PerlTimeline But hey! You only feel 5 cents poorer each time. -- Larry Wall in [email protected] UNIX is born at Bell Labs. It was not until well into 1970 that Brian Kernighan suggested the name `Unix,' in a somewhat treacherous pun on `Multics,' the operating system we know today was born.
    [Show full text]