0% found this document useful (0 votes)
298 views

PERL Cheat Sheet

This document provides a summary of key Perl concepts, data types, operators, and functions. It lists special symbols used to indicate variables, arrays, subroutines, and regular expressions. Useful reserved keywords like print, for, foreach, while, and exit are described. Finally, it notes some common Perl modules and functions like split, chomp, sleep, and ARGV that are used for string manipulation, I/O, and flow control.

Uploaded by

Anupam Lalit
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
298 views

PERL Cheat Sheet

This document provides a summary of key Perl concepts, data types, operators, and functions. It lists special symbols used to indicate variables, arrays, subroutines, and regular expressions. Useful reserved keywords like print, for, foreach, while, and exit are described. Finally, it notes some common Perl modules and functions like split, chomp, sleep, and ARGV that are used for string manipulation, I/O, and flow control.

Uploaded by

Anupam Lalit
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

PERL Cheat Sheet

PERL Practical Extraction and Reporting Language or the Pathologically Eclectic Rubbish Lister Special Symbols $@%within within ;{} /patterns &variables <>$! @_ subroutines $ $$ $#arrayName Indicates a variable Indicates a standard array(a list) Indicates an associative array(a hash table) Single quote tells PERL not to interpret anything Double quote tells PERL it is Ok to interpret what is Used to end a statement Curly brackets Used to contain a block of code Used in RegEx pattern matching or replacement Used when calling a subroutine if you want to pass in Deathstar Used to snarf in all of the data from a file handle The last error reported Used to pass variables and other stuff into List separator Process ID of the currently running process Index of the last element of an array/list

Useful Reserved Keywords (WARNING: By no means all of them) print Print to STDOUT or a file handle print This goes to STDOUT; print aFileHandle This goes to a file handle; Indicated the following block of code is a subroutine Starts a for loop for(i = 0; i < aVariable; i++) { Do something; }

sub for -

foreach -

Used to iterate over all members of an array foreach $element (@someArray) { Do something to $element; }

while -

Starts a while loop while(conditional) { Do Something; } Use pragma Used to import routines from a module Splits up a string on delimiters Take the last character off but only if it is a newline

use split chomp -

chop Take the last character off regardless of what it is(parent of chomp) exit you put in die Exit the program immediately with a message Exit the program immediately exit exit <a number> -exits with an exit code of the number

goto Goes to a particular label in the program, generally considered sloppy keys my next push pop return Find the current keys of an associative array Makes a variable local to a subroutine , used to avoid name space collisions Used in flow control to skip to the next entry if you dont want to process it Adds an new entry to an array/list Retrieves and removes an entry from an array/list Returns a variable or something from a subroutine

shift -

Shifts the first value off of an array and returns it. The same as pop, but usually used for retrieving variables and other things passed into a subroutine in the special variable @_ Sleep for a specified number of seconds sleep 1; Sleep for 1 second Array of command line arguments The author of this document does not always follow the conventional wisdom of programming PERL

sleep ARGV -

Caveat Emptor

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy