Perl - Tutorialspoint

3y ago
97 Views
6 Downloads
898.70 KB
39 Pages
Last View : 3m ago
Last Download : 3m ago
Upload by : Tripp Mcmullen
Transcription

PerlAbout the TutorialPerl is a programming language developed by Larry Wall, especially designed for textprocessing. It stands for Practical Extraction and Report Language. It runs on avariety of platforms, such as Windows, Mac OS, and the various versions of UNIX.This tutorial provides a complete understanding on Perl.AudienceThis reference has been prepared for beginners to help them understand the basic toadvanced concepts related to Perl Scripting languages.PrerequisitesBefore you start practicing with various types of examples given in this reference, we aremaking an assumption that you have prior exposure to C programming and Unix Shell.Copyright & Disclaimer Copyright 2015 by Tutorials Point (I) Pvt. Ltd.All the content and graphics published in this e-book are the property of Tutorials Point (I)Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republishany contents or a part of contents of this e-book in any manner without written consentof the publisher.We strive to update the contents of our website and tutorials as timely and as precisely aspossible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt.Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of ourwebsite or its contents including this tutorial. If you discover any errors on our website orin this tutorial, please notify us at contact@tutorialspoint.comi

PerlTable of ContentsAbout the Tutorial . iAudience . iPrerequisites . iCopyright & Disclaimer . iTable of Contents . iiPART 1: PERL – BASICS . 11.Perl Introduction . 2What is Perl?. 2Perl Features. 2Perl and the Web . 3Perl is Interpreted . 32.Perl Environment . 4Unix and Linux Installation . 5Running Perl . 63.Perl Syntax Overview . 9Script Mode Programming . 94.Perl Data Types . 15Numeric Literals. 15String Literals . 165.Perl Variables . 19Creating Variables . 196.Perl Scalars . 23Scalar Operations . 257.Perl Arrays . 288.Perl Hashes . 399.Perl If Else. 45if statement . 46if.else statement . 48if.elsif.else statement . 50unless statement . 51unless.else statement . 53unless.elsif.else statement . 55switch statement . 56The ? : Operator . 5910. Perl Loops . 61while loop . 62ii

Perluntil loop . 64for loop . 66foreach loop . 68do.while loop . 70nested loops . 71Loop Control Statements . 74next statement . 74last statement . 77continue statement . 80redo statement . 82goto statement . 83The Infinite Loop . 8611. Perl Operators . 87What is an Operator? . 87Perl Arithmetic Operators . 87Perl Equality Operators . 89Perl Assignment Operators. 94Perl Bitwise Operators . 96Perl Logical Operators . 98Quote-like Operators . 100Miscellaneous Operators. 101Perl Operators Precedence. 10312. Perl Date and Time . 106GMT Time . 107Format Date & Time . 107Epoch time . 108POSIX Function strftime() . 10913. Perl Subroutines . 112Define and Call a Subroutine . 112Passing Arguments to a Subroutine . 113Passing Lists to Subroutines . 114Passing Hashes to Subroutines . 114Returning Value from a Subroutine . 115Private Variables in a Subroutine . 116Temporary Values via local() . 117State Variables via state() . 118Subroutine Call Context . 11914. Perl References . 121Create References . 121Dereferencing . 122Circular References. 123References to Functions . 124iii

Perl15. Perl Formats . 126Define a Format . 126Using the Format . 127Define a Report Header . 128Number of Lines on a Page . 131Define a Report Footer . 13116. Perl File I/O . 132Opening and Closing Files . 132Open Function . 132Sysopen Function . 134Close Function . 135The FILEHANDL Operator . 135getc Function . 136read Function . 136print Function . 136Copying Files . 137Renaming a file . 137Deleting an Existing File . 138Positioning inside a File . 138File Information . 13917. Perl Directories . 142Display all the Files . 142Create new Directory . 144Remove a directory . 144Change a Directory . 14418. Perl Error Handling . 145The if statement . 145The unless Function . 145The ternary Operator . 146The warn Function . 146The die Function . 146Errors within Modules . 146The carp Function . 147The cluck Function . 148The croak Function . 149The confess Function . 14919. Perl Special Variables . 151Special Variable Types . 152Global Scalar Special Variables . 152Global Array Special Variables .

Perl is an Open Source software, licensed under its Artistic License, or the GNU General Public License (GPL). Perl was created by Larry Wall. Perl 1.0 was released to usenet's alt.comp.sources in 1987. At the time of writing this tutorial, the latest version of perl was 5.16.2. Perl is listed in the Oxford English Dictionary.

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