Intermediate Perl

2y ago
21 Views
3 Downloads
696.25 KB
96 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Nora Drum
Transcription

Intermediate Perl#!/usr/bin/perl wuse strict; ’eval("seek\040DATA,0,0;");foreach(1.2){ DATA ;}my@camel1hump;my camel;my Camel ;while( DATA ){ sprintf("% 69s", );my@dromedary1 split(//);if(defined( DATA )){@camel1hump split(//);}while(@dromedary1){my camel1hump 0;my CAMEL 3;if(defined( shift(@dromedary1))&&/\S/){ camel1hump 1 CAMEL;} CAMEL ;if(defined( shift(@dromedary1))&&/\S/){ camel1hump 1 CAMEL;} CAMEL ;if(defined( shift(@camel1hump))&&/\S/){ camel1hump 1 CAMEL;} CAMEL ;if(defined( shift(@camel1hump))&&/\S/){ camel1hump 1 CAMEL;;} camel. (split(//,"\040.m‘{/J\047\134}L 7FX"))[ camel1hump];} camel. "\n";}@camel1hump split(/\n/, camel);foreach(@camel1hump){chomp; Camel 5678/JL7F\175\173\047‘/; reverse;print" \040 Camel\n";}foreach(@camel1hump){chomp; Camel 175\173\047‘/; reverse;print"\040 Camel\n";}#japh );undef /; DATA ;s \s* g;();;s; .* ;;;map{eval"print\" \"";}/.{4}/g; DATA\124\150\145\040\165\163\145\040\157\1 46\040\1 41\040\143\141 \155\145\1 54\040\151\155\ 141\147\145\0 40\151\156 \040\141\163\16 3\157\143\151\141\16 4\151\157\156\040\167 \146\040\117\047\122\145\151\154\1 44\040\167\151\164\1 Kirrily RobertPaul FenwickJacinta Richardson

Intermediate Perlby Kirrily Robert, Paul Fenwick, and Jacinta RichardsonCopyright 1999-2000 Netizen Pty LtdCopyright 2000 Kirrily RobertCopyright 2001 Obsidian Consulting Group Pty LtdCopyright 2001-2005 Paul Fenwick (pjf@perltraining.com.au)Copyright 2001-2005 Jacinta Richardson (jarich@perltraining.com.au)Copyright 2001-2005 Perl Training AustraliaOpen Publications License 1.0Cover artwork Copyright (c) 2000 by Stephen B. Jenkins. Used with permission.The use of a camel image with the topic of Perl is a trademark of O’Reilly & Associates, Inc. Used with permission.This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latestversion is presently available at http://www.opencontent.org/openpub/).Distribution of this work or derivative of this work in any standard (paper) book form is prohibited unless prior permission is obtained fromthe copyright holder.This document is a revised and edited copy of the training notes originally created by Kirrily Robert and Netizen Pty Ltd. These revisionswere made by Paul Fenwick and Jacinta Richardson.Copies of the original training manuals can be found at http://sourceforge.net/projects/sporkThis training manual is maintained by Perl Training Australia, and can be found at http://www.perltraining.com.au/notes.htmlThis is version 4.23 of Perl Training Australia’s "Intermediate Perl" training manual.

Table of Contents1. About Perl Training Australia . 1Training . 1Consulting . 1Contact us. 12. Introduction. 3Credits . 3Course outline . 3Day 1 . 3Day 2 . 3Assumed knowledge . 3Module objectives . 3Platform and version details. 4The course notes. 4Other materials . 5Logging into your account . 53. References and complex data structures . 7In this chapter. . 7Assumed knowledge . 7Introduction to references . 7Uses for references. 7Creating complex data structures . 7Passing arrays and hashes to subroutines and functions. 7Object oriented Perl. 8Creating and dereferencing references. 8Exercises. 9Assigning through references . 9Passing multiple arrays/hashes as arguments. 10Anonymous data structures . 11Exercise . 12Complex data structures. 12Exercises . 13Disambiguation and curly braces. 13Data::Dumper. 14Exercises. 16Chapter summary . 164. External Files and Packages . 17In this chapter. . 17Splitting code between files . 17Require . 17Use strict and warnings . 18Example. 18Exercises . 19Introduction to packages . 19The scoping operator. 20Exercises . 21Package variables and our . 22Exercises . 22Chapter summary . 22Perl Training Australia (http://www.perltraining.com.au/)iii

5. Modules. 25In this chapter. . 25Module uses . 25What is a module?. 25Exercise . 26Where does Perl look for modules? . 26Finding installed modules . 26Exercise . 27Using CPAN modules. 27The double-colon . 27Writing modules. 28Use versus require . 29Warnings and strict . 29Exercise . 29Things to remember. . 30Exporting and importing subroutines. 30@ISA . 30use base . 30An example. 31Exporting by default . 31An example. 31Importing symbols. 32Exercises. 33Exporting tags. 33Importing symbols through tags. 33Exercise . 33Chapter summary . 346. Using Perl objects . 35In this chapter. . 35Objects in brief. 35Using an object. 35Instantiating an object. 36Calling methods on an object . 36Destroying an object. 36Chapter summary . 377. Advanced regular expressions . 39In this chapter. . 39Assumed knowledge . 39Capturing matched strings to scalars . 39Extended regular expressions. 40Exercise . 41Advanced Exercise. 41Greediness. 41Exercise . 42More meta characters . 42Working with multi-line strings . 43Exercise . 45Regexp modifiers for multi-line data. 45Back references . 46Special variables . 46Exercises. 47ivPerl Training Australia (http://www.perltraining.com.au/)

Advanced Exercises. 48Chapter summary . 488. File I/O . 49In this chapter. . 49Assumed knowledge . 49Angle brackets - the line input and globbing operators . 49Exercises. 50Advanced exercises. 50open() and friends - the gory details . 50Opening a file for reading, writing or appending . 51Exercises . 53Reading directories. 54glob and readdir . 55rewinddir . 55Changing directories . 56Exercises . 56Changing file contents . 56Exercises . 58Opening files for simultaneous read/write. 58Opening pipes. 59Exercises . 60Finding information about files. 60Exercises. 62Recursing down directories. 62Exercises. 63File locking . 63Handling binary data.

Chapter 2. Introduction Welcome to Perl Training Australia’s Intermediate Perl training course. This is a two-day module in which we extend on the material covered in Introduction to Perl and explore the topics of references, file input and output, interacting wit

Related Documents:

Why Perl? Perl is built around regular expressions -REs are good for string processing -Therefore Perl is a good scripting language -Perl is especially popular for CGI scripts Perl makes full use of the power of UNIX Short Perl programs can be very short -"Perl is designed to make the easy jobs easy,

Perl can be embedded into web servers to speed up processing by as much as 2000%. Perl's mod_perl allows the Apache web server to embed a Perl interpreter. Perl's DBI package makes web-database integration easy. Perl is Interpreted Perl is an interpreted language, which means that your code can be run as is, without a

Other Perl resources from O’Reilly Related titles Learning Perl Programming Perl Advanced Perl Programming Perl Best Practices Perl Testing: A Developer’s . Intermedi

Run Perl Script Option 3: Create a Perl script my_script.pl: Run my_script.pl by calling perl: 8/31/2017 Introduction to Perl Basics I 10 print Hello World!\n; perl ./my_script.pl Option 4: For a small script with several lines, you can run it directly on the command line: perl -e print Hello World!\n;

Perl's creator, Larry Wall, announced it the next day in his State of the Onion address. Most notably, he said "Perl 6 is going to be designed by the community." Everyone thought that Perl 6 would be the version after the just-released Perl v5.6. That didn't happen, but that's why "Perl" was in the name "Perl 6."

tutorial Sorry about that but I have to keep my tutorial's example scripts short and to the point Finally, this is a tutorial for Perl/Tk only I will not be teaching perl here So if you know perl, continue But if you are a beginner to perl, I would recommend that you read my perl tutorial

Run Perl Script Option 3: Create a Perl script my_script.pl: Run my_script.pl by calling perl: 8/31/2017 Introduction to Perl Basics I 10 print Hello World!\n; perl ./my_script.pl Option 4: For a small script with several lines, you can run it directly on the command line: perl -e print Hello World!\n;

Introduction to Perl Pinkhas Nisanov. Perl culture Perl - Practical Extraction and Report Language Perl 1.0 released December 18, 1987 by Larry Wall. Perl culture Perl Poems BEFOREHAND: close door, each window & exit; wait until time. open spellbook, study, read (scan, select, tell us);