PROGRAMMING with PERL CGI Programming with Perl

PROGRAMMING with PERL CGI Programming with Perl

▼ ▼ ▼ ZDU Student Manual CGI PROGRAMMING WITH PERL CGI Programming with Perl ISBN: 0-73725-354-1 Part number: ZDU56708 ACKNOWLEDGMENTS Content Development The content of this self-study guide is based on the training course "CGI Programming with PerlCGI Programming with Perl," developed by Instruction Set, Inc. for its curriculum of instructor-led technical training. This guide was designed and developed by an Instruc- tion Set team of instructional designers, course developers, and editors. Administration Vice President and General Manager of ZD University: Ed Passarella Marketing Director: Risa Edelstein Director, ZD University: George Kane Senior Editor, Curriculum: Jennifer Golden Project Director, Instruction Set: Laurie Poklop Project Manager, Instruction Set: Sandy Tranfaglia DISCLAIMER While Ziff-Davis Education takes great care to ensure the accuracy and quality of these materials, all material is provided without any warranty whatsoever, including, but not limited to, the implied war- ranties of merchantability or fitness for a particular purpose. Trademark Notices: ZD University and Ziff-Davis Education are trademarks and service marks of Ziff- Davis Inc. CGI Programming with Perl is a Copyright of Instruction Set, Inc. All other product names and services used throughout this book are trademarks or registered trademarks of their respective companies. The product names and services are used throughout this book in editorial fashion only and for the benefit of such companies. No such use, or the use of any trade name, is intended to convey endorsement or other affiliation with the book. Copyright © 1998 Instruction Set, Inc. All rights reserved. This publication, or any part thereof, may not be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, storage in an information retrieval system, or otherwise, without the prior written permission of Instruction Set, Inc., 16 Tech Circle, Natick, MA 01760, (508) 651-9085, (800) 874-6738. Instruction Set’s World Wide Web site is located at http://www.InstructionSet.com. ZD University’s World Wide Web site is located at http://www.zdu.com. Photocopying any part of this book without the prior written consent of Instruction Set, Inc. is a vio- lation of federal law. If you believe that Instruction Set materials are being photocopied without per- mission, please call 1-800-874-6738 CONTENTS CGI Programming with Perl LESSON 1: GETTING STARTED WITH PERL Objectives . 2 What is Perl? . 2 Obtaining and Installing Perl . .4 Perl Resources . .5 Perl Options . 6 Locating Perl on the System . 7 Running Perl Programs as Interpreter Files . 7 Basic Statement Syntax . 8 Comments . .9 Variables . 9 Basic Operators . 10 Simple Control Constructs . 11 Using Functions. 12 The chomp() and chop() Functions. .12 Standard Input and Output . 13 Reading from Standard Input. .13 Writing to Standard Output and Standard Error. .14 A Simple Example . .15 Lesson Summary . 16 Review Questions . 17 Exercise . 18 LESSON 2: GETTING STARTED WITH CGI Objectives . 20 Web Server and Client Communication . 20 ii CGI PROGRAMMING WITH PERL Setting Up a CGI Program . 22 Common Mistakes . 22 Lesson Summary . 25 Review Questions . 26 Exercise . 27 LESSON 3: OPERATORS Objectives . 30 Arithmetic Operators . 30 Autoincrement and Autodecrement Operators . .31 Relational Operators . 32 Relational Operators for Numbers . .32 Relational Operators for Strings. .33 Logical Operators . 33 String Operators . 35 Assignment Operators . 35 Precedence . 37 Lesson Summary . 38 Review Questions . 39 Exercise . 41 LESSON 4: FLOW CONTROL Objectives . 44 True and False in Perl . 44 The if-else statement. .45 The elseif Statement. .46 The warn(), die(), and exit() Functions . 47 The while Loop. 48 The for Loop . 49 The foreach Loop . 50 The last Statement. 51 The Many Ways to Do Something . 52 Lesson Summary . 55 Review Questions . 56 Exercise . 57 CONTENTS iii LESSON 5: WORKING WITH SCALARS Objectives . 60 Scalar Variables . 60 Integer Scalar Values. 60 Floating Point Scalar Values . 61 Character Strings. 62 Escape Sequences . 63 Conversions Between Numbers and Strings . 64 Initial Values . 65 Explicit Conversion Between Numbers and Strings . 66 The $_ Variable. 67 Lesson Summary . 68 Review Questions . 69 Exercise . 71 LESSON 6: WORKING WITH LISTS Objectives . 74 What is a List? . 74 Storing Lists as Constants . 75 Defining and Using List Variables . 76 Working with Lists . 77 Accessing Individual List Elements. 77 Assigning List Elements to Other Variables . 78 Retrieving the Length of a List . 80 Command Line Arguments. 80 Adding and Removing Elements at Either End . 81 Manipulating Lists . 83 Sorting a List . 83 Reversing the Order of a List. ..

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    220 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us