Programming Perl - Southeastern Louisiana University

2y ago
17 Views
3 Downloads
1.44 MB
192 Pages
Last View : 18d ago
Last Download : 2m ago
Upload by : Oscar Steel
Transcription

Programming 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

Programming Perlby Kirrily Robert, Paul Fenwick, and Jacinta RichardsonCopyright 1999-2000 Netizen Pty LtdCopyright 2000 Kirrily RobertCopyright 2001 Obsidian Consulting Group Pty LtdCopyright 2001-2007 Paul Fenwick (pjf@perltraining.com.au)Copyright 2001-2007 Jacinta Richardson (jarich@perltraining.com.au)Copyright 2001-2007 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 Introduction to Perl and Intermediate Perl training notes originally created by KirrilyRobert and Netizen Pty Ltd. These revisions were 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 1.13 of Perl Training Australia’s "Programming Perl" training manual.

Table of Contents1. About Perl Training Australia . 1Training . 1Consulting . 1Contact us. 12. Introduction. 3Credits . 3Course outline . 3Day 1 . 3Day 2 . 3Day 3 . 3Day 4 . 3Assumed knowledge . 4Platform and version details. 4The course notes. 4Other materials . 53. What is Perl . 7In this chapter. . 7Perl’s name and history . 7Typical uses of Perl . 7Text processing . 7System administration tasks . 7CGI and web programming. 7Database interaction . 8Other Internet programming. 8Less typical uses of Perl . 8What is Perl like? . 8The Perl Philosophy . 9There’s more than one way to do it . 9A correct Perl program. . 9Three virtues of a programmer. 9Laziness. 9Impatience. 9Hubris. 9Three more virtues. 10Share and enjoy! . 10Parts of Perl . 10The Perl interpreter. 10Manuals/Documentation. 10Perl Modules. 11Chapter summary . 114. A brief guide to perldoc. 13Using perldoc . 13Exercise . 13Language features and tutorials . 13Looking up functions . 13Looking up modules. 14Perl Training Australia (http://perltraining.com.au/)iii

5. Creating and running a Perl program. 15In this chapter. . 15Logging into your account . 15Our first Perl program . 15Running a Perl program from the command line. 15Executing code . 16The "shebang" line for Unix. 16The "shebang" line for non-Unixes . 17Comments . 17Block comments . 17END . 17Command line options . 18Chapter summary . 186. Perl variables. 19In this chapter. . 19What is a variable? . 19Variable names . 19Variable scoping and the strict pragma . 19Arguments in favour of strictness. 20Arguments against strictness . 20Using the strict pragma (predeclaring variables). 20Exercise. 21Using the diagnostics pragma. 21Exercise. 21Starting your Perl program . 21Scalars . 22Double and single quotes . 23Exercise . 23Special characters . 23Advanced variable interpolation. 24Exercises. 24Arrays. 25Initialising an array. 25Reading and changing array values . 25Array slices . 26Array interpolation . 26Counting backwards . 26Finding out the size of an array . 26Using qw// to populate arrays. 27Printing out the values in an array . 27A quick look at context. 28What’s the difference between a list and an array? . 29Exercises. 29Advanced exercises . 29Hashes . 29Initialising a hash. 30Reading hash values . 30Adding new hash elements . 31Changing hash values . 31Deleting hash values. 31Finding out the size of a hash . 31ivPerl Training Australia (http://perltraining.com.au/)

Other things about hashes. 31Exercises. 32Special variables. 32The special variable . 33@ARGV - a special array. 33%ENV - a special hash . 33Exercises. 34Chapter summary . 347. Operators and functions. 37In this chapter. . 37What are operators and functions?. 37Operators. 37Arithmetic operators. 37String operators . 38Exercises. 38Other operators . 39Functions. 39Types of arguments. 40Return values . 41More about context . 41Some easy functions. 42String manipulation . 42Finding the length of a string . 42Case conversion . 42chop() and chomp(). 43String substitutions with substr() . 43Exercises . 44Numeric functions . 44Type conversions . 44Manipulating lists and arrays. 45Stacks and queues .

This document is a revised and edited copy of the Introduction to Perl and Intermediate Perl training notes originally created by Kirrily Robert and Netizen Pty Ltd. These revisions

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);