<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://halfface.se/wiki/index.php?action=history&amp;feed=atom&amp;title=Perl</id>
	<title>Perl - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://halfface.se/wiki/index.php?action=history&amp;feed=atom&amp;title=Perl"/>
	<link rel="alternate" type="text/html" href="https://halfface.se/wiki/index.php?title=Perl&amp;action=history"/>
	<updated>2026-04-19T07:27:37Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://halfface.se/wiki/index.php?title=Perl&amp;diff=12910&amp;oldid=prev</id>
		<title>Ekaanbj: /* Debug */</title>
		<link rel="alternate" type="text/html" href="https://halfface.se/wiki/index.php?title=Perl&amp;diff=12910&amp;oldid=prev"/>
		<updated>2017-10-25T21:11:44Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Debug&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Reading==&lt;br /&gt;
 http://www.perl.org/books/beginning-perl/&lt;br /&gt;
&lt;br /&gt;
==Perl==&lt;br /&gt;
Pathologically Eclectic Rubbish Lister&lt;br /&gt;
 Larry Wall wrote it.&lt;br /&gt;
==useful commands==&lt;br /&gt;
 scalar localtime # Generate date&lt;br /&gt;
=remove linefeed on last line=&lt;br /&gt;
 perl -pe &amp;#039;chomp if eof&amp;#039;&lt;br /&gt;
&lt;br /&gt;
=convert epoch unix time to iso date=&lt;br /&gt;
 perl -ne &amp;#039;use POSIX; s/([\d.]+)/strftime &amp;quot;%Y-%m-%d %H:%M:%S&amp;quot;, localtime $1/e,print if /./&amp;#039;&lt;br /&gt;
&lt;br /&gt;
==variables==&lt;br /&gt;
the three types of variables in Perl are:&lt;br /&gt;
 scalars = numbers, strings, or references    denoted $ &lt;br /&gt;
 arrays = sequentially-numbered lists of scalars     denoted @&lt;br /&gt;
 hashes.= key-referenced lists of scalars     denoted %&lt;br /&gt;
 &lt;br /&gt;
==boolean operators==&lt;br /&gt;
 Operator                   Num     Str&lt;br /&gt;
 --------------------------------------&lt;br /&gt;
 Equal                      ==      eq&lt;br /&gt;
 Not equal                  !=      ne&lt;br /&gt;
 Less than                   &amp;lt;      lt&lt;br /&gt;
 Greater than                &amp;gt;      gt&lt;br /&gt;
 Less than or equal to      &amp;lt;=      le&lt;br /&gt;
 Greater than or equal to   &amp;gt;=      ge&lt;br /&gt;
&lt;br /&gt;
==man pages==&lt;br /&gt;
 perl      - overview               perlfaq   - frequently asked questions&lt;br /&gt;
 perltoc   - doc TOC                perldata  - data structures&lt;br /&gt;
 perlsyn   - syntax                 perlop    - operators and precedence&lt;br /&gt;
 perlrun   - execution              perlfunc  - builtin functions&lt;br /&gt;
 perltrap  - traps for the unwary   perlstyle - style guide&lt;br /&gt;
 &lt;br /&gt;
 &amp;quot;perldoc&amp;quot; and &amp;quot;perldoc -f&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==cpan==&lt;br /&gt;
 Comprehensive perl archive network&lt;br /&gt;
&lt;br /&gt;
==Perl kurs==&lt;br /&gt;
 Christer Ekholm&lt;br /&gt;
 First two letters and first letter of last name@init.se&lt;br /&gt;
 TIMTOWTDI (There Is More Than One Way To Do It)&lt;br /&gt;
 &lt;br /&gt;
==Dictionary==&lt;br /&gt;
 regexp		regular expression . a* a? ^a a$,perls RE för andra.&lt;br /&gt;
 semantik	meaning that is expressed in a language and words&lt;br /&gt;
 notation	ways to represent a mathematical equation&lt;br /&gt;
 analogi		motsvarighet, nagot svart beskrivs enkelt&lt;br /&gt;
 iteration	upprepning&lt;br /&gt;
 deklarera	förklara&lt;br /&gt;
 definera	definera subrutiner&lt;br /&gt;
 context		sammanhang&lt;br /&gt;
 explicit	uttryckligen&lt;br /&gt;
 implicit	underförstått&lt;br /&gt;
 logiska operatorer	and,or,not,||,&amp;amp;&amp;amp;,!&lt;br /&gt;
 aritmetisk	+-/*&lt;br /&gt;
 bitoperatorer	AND,OR,XOR,leftand right shift.&lt;br /&gt;
 re		reguljära utryck, mönsterpassning.&lt;br /&gt;
 statement	If functions are the verbs of Perl, then statements are the sentences.&lt;br /&gt;
 scalar literal constant	varaiable that cant change&lt;br /&gt;
 interpolated	Variable has been expanded&lt;br /&gt;
 Boolean operators	The idea of combining values that represent truth and falsehood is called Boolean logic,after George Boole, who invented the concept in 1847, and we call the operators that do the combining &amp;#039;Boolean operators&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
==functions (Commands operator)==&lt;br /&gt;
 rename($target,$target.&amp;quot;.old&amp;quot;)   # Rename a file.&lt;br /&gt;
 glob(&amp;quot;*l&amp;quot;);   # List all files ending with l&lt;br /&gt;
 print $_, &amp;quot; &amp;quot; x (30-length($_));   # The length of the file name plus the number of spaces will always add up to thirty, so we have nicely arranged columns&lt;br /&gt;
&lt;br /&gt;
==comparison==&lt;br /&gt;
 #!/usr/bin/perl&lt;br /&gt;
 use warnings;&lt;br /&gt;
 print&amp;quot;Is two equal to four? &amp;quot;, 2 == 4, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 print &amp;quot;OK, then, is six equal to six? &amp;quot;, 6 == 6, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 print&amp;quot;So, two isn&amp;#039;t equal to four? &amp;quot;, 2 != 4, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 print&amp;quot;Five is more than six? &amp;quot;, 5 &amp;gt; 6, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 print &amp;quot;Seven is less than sixteen? &amp;quot;, 7 &amp;lt; 16, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 print &amp;quot;Two is equal to two? &amp;quot;, 2 == 2, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 print &amp;quot;One is more than one? &amp;quot;, 1 &amp;gt; 1, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 print &amp;quot;Six is not equal to seven? &amp;quot;, 6 != 7, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 print&amp;quot;Seven is less than or equal to sixteen? &amp;quot;, 7 &amp;lt;= 16, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 print &amp;quot;Two is more than or equal to two? &amp;quot;, 2 &amp;gt;= 2, &amp;quot;\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
 Is two equal to four?&lt;br /&gt;
 OK, then, is six equal to six? 1&lt;br /&gt;
 So, two isn&amp;#039;t equal to four? 1&lt;br /&gt;
 Five is more than six?&lt;br /&gt;
 Seven is less than sixteen? 1&lt;br /&gt;
 Two is equal to two? 1&lt;br /&gt;
 One is more than one?&lt;br /&gt;
 Six is not equal to seven? 1&lt;br /&gt;
 Seven is less than or equal to sixteen? 1&lt;br /&gt;
 Two is more than or equal to two? 1&lt;br /&gt;
&lt;br /&gt;
 print &amp;quot;1 &amp;lt;= 0 =&amp;gt; -1&amp;quot;, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 print &amp;quot;Compare six and nine? &amp;quot;, 6 &amp;lt;=&amp;gt; 9, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 print &amp;quot;Compare seven and seven? &amp;quot;,7 &amp;lt;=&amp;gt; 7, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 print &amp;quot;Compare eight and four? &amp;quot;, 8 &amp;lt;=&amp;gt; 4, &amp;quot;\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
 print 6 &amp;gt; 3 &amp;amp;&amp;amp; 12 &amp;gt; 4, &amp;quot;\n&amp;quot;; # 1&lt;br /&gt;
 print 9 &amp;gt; 7 || 6 &amp;gt; 8, &amp;quot;\n&amp;quot;;  # 1&lt;br /&gt;
 print !(2&amp;gt;3), &amp;quot;\n&amp;quot;;          # 1&lt;br /&gt;
 print !2&amp;gt;3, &amp;quot;\n&amp;quot;;            # 0&lt;br /&gt;
&lt;br /&gt;
==How to get information==&lt;br /&gt;
 perldoc -f variabler	Show help page for variables&lt;br /&gt;
 perldoc -f -X		Show file handle test.&lt;br /&gt;
 perldoc perlform	Format information&lt;br /&gt;
 perldoc Getopt::Long	Show help for Getopt&lt;br /&gt;
 perldoc -q		Letar i perl faq&lt;br /&gt;
 perldoc perlmodlib	Lista inbyggda moduler&lt;br /&gt;
 perldoc perlpod&lt;br /&gt;
&lt;br /&gt;
==Debug==&lt;br /&gt;
 emacs M-x perldb	Debugga perl i emacs&lt;br /&gt;
 perl -d:ptkdb /scrpt	Debugga perl&lt;br /&gt;
 perl -d:Trace # yum install perl-Devel-Trace&lt;br /&gt;
 http://www.drdobbs.com/using-the-perl-debugger/184404744&lt;br /&gt;
&lt;br /&gt;
==Perl code==&lt;br /&gt;
 use strict;	explesist namnge package variable&lt;br /&gt;
 use warning;	show warning messages&lt;br /&gt;
 perl -w		show warning messages&lt;br /&gt;
 use Getopt::Long:	Use getoptions module&lt;br /&gt;
&lt;br /&gt;
package mypkg;	change package&lt;br /&gt;
&lt;br /&gt;
==use base==&lt;br /&gt;
&lt;br /&gt;
 use base qw(Mother Father);&lt;br /&gt;
&lt;br /&gt;
This pragma lets a programmer conveniently declare a derived class based upon the listed parent classes. The declaration above is roughly equivalent to:&lt;br /&gt;
    BEGIN {&lt;br /&gt;
        require Mother;&lt;br /&gt;
        require Father;&lt;br /&gt;
        push @ISA, qw(Mother Father);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
==Perl Oneliners:==&lt;br /&gt;
 perl -ne &amp;#039;print if /a/&amp;#039;			Grep all lines containing a. (-n create a loop) (-e, allows you to define Perl code to be executed by the compiler)&lt;br /&gt;
 perl -e &amp;#039;print join(&amp;quot;\n&amp;quot;,@INC),&amp;quot;\n&amp;quot;&amp;#039;	Var söker perl efter moduler&lt;br /&gt;
 perl -c kod.pl				Kontrollera koden.&lt;br /&gt;
&lt;br /&gt;
==regex==&lt;br /&gt;
 .		one key&lt;br /&gt;
 ^		beginning of line&lt;br /&gt;
 $		end of line&lt;br /&gt;
 /^[xfi]/	Starting with one x or f or i&lt;br /&gt;
 /^[h-j]/	Starting with one h or i or j&lt;br /&gt;
 ()		Deluttryck&lt;br /&gt;
 quantifier	how much a string matches.&lt;br /&gt;
 ?		Noll eller en gång&lt;br /&gt;
 a*		a with 0 to unlimit a&lt;br /&gt;
 a+		one or more a&lt;br /&gt;
 {m}		exackt m ggr&lt;br /&gt;
 {m,}		minst m ggr&lt;br /&gt;
 {m,n}		minst m max n ggr&lt;br /&gt;
 =~ m|^abc|	match with alternate delimiter a line starting with abc.&lt;br /&gt;
 =~ 		Match regexp. If pattern found return 1 else undefined.&lt;br /&gt;
 !~ 		Match regexp. If pattern is not found return 1 else undefined.&lt;br /&gt;
 .+?		matchar så lite som möjligt&lt;br /&gt;
&lt;br /&gt;
==regexp modifiers==&lt;br /&gt;
 /i/i		matchar i case insensitiv&lt;br /&gt;
 a.b		a any key b&lt;br /&gt;
 ^a.c$		starting with a any key end with c&lt;br /&gt;
 X1*		X1 folles by 0 to many 1&lt;br /&gt;
 ^[]abc]		strings starting with any of ]abc&lt;br /&gt;
 [^zxy]		Does not have any of zxy in possition&lt;br /&gt;
 a{8}		aaaaaaaa&lt;br /&gt;
 uttr{m,n}	uttr förekommer mellan m och n gånger&lt;br /&gt;
 ^ *$		empty line or only blanks&lt;br /&gt;
&lt;br /&gt;
==Special meaning==&lt;br /&gt;
 $		skalär&lt;br /&gt;
 @		lista&lt;br /&gt;
 %		hash, associativa vektorer&lt;br /&gt;
 $#		maximun index in list&lt;br /&gt;
 $@		string that eval generates.&lt;br /&gt;
 \s		remove space,tab,lf...&lt;br /&gt;
 \s+		godtyckligt&lt;br /&gt;
 \l		Convert to lower case.&lt;br /&gt;
 $_		Default output input, the special $_ variable, which is often used in Perl functions as a &amp;#039;default value&amp;#039;.&lt;br /&gt;
 $$		processid&lt;br /&gt;
 $?		exit status&lt;br /&gt;
 @_		variable to send to subroutin&lt;br /&gt;
 @ARGV		argument list. (&amp;#039;-v&amp;#039;,&amp;#039;-g&amp;#039;,&amp;#039;10&amp;#039;,&amp;#039;logfile&amp;#039;)&lt;br /&gt;
 $|=1;		dont flush output stty&lt;br /&gt;
 $&amp;quot;=&amp;#039;,&amp;#039;;		dubbelfnuttade listor&lt;br /&gt;
 _		fil operatorer och stat kan återänväda stat förfrågan.&lt;br /&gt;
 $.		Radräknare&lt;br /&gt;
 $1		Delutryck som matchade&lt;br /&gt;
 local $/	&lt;br /&gt;
 @INC		directories to find per modules, add directory export PERL5LIB=/bin:/hej&lt;br /&gt;
 &lt;br /&gt;
 &amp;amp;sub		subrutin&lt;br /&gt;
 $var2=\$var	refere var2 to var&lt;br /&gt;
 @list(&amp;#039;a&amp;#039;,1,$a)	add tree elements to list&lt;br /&gt;
 @list([@odd])	add copy of list called anonymous list&lt;br /&gt;
 $list[5]	6 possition in list&lt;br /&gt;
 @list = qw&amp;lt;Jan Feb&amp;gt;;	Generate list&lt;br /&gt;
 &lt;br /&gt;
 $hash{&amp;#039;var&amp;#039;}	element with index var in hash&lt;br /&gt;
 %hash{&amp;#039;a&amp;#039;}=&amp;#039;5&amp;#039;;	add key a value 5&lt;br /&gt;
 if (exist($hash{a})){	run if key a exist i hash hash&lt;br /&gt;
 delete($hash{&amp;#039;a&amp;#039;});	delete key a fron hash&lt;br /&gt;
 split(&amp;#039; &amp;#039;,$str);	split list output whith &amp;#039; &amp;#039;&lt;br /&gt;
&lt;br /&gt;
 my		lexikal variabel, lokal variabel&lt;br /&gt;
 $main::var	main variabel&lt;br /&gt;
&lt;br /&gt;
==styrstrukturer==&lt;br /&gt;
*iterationer&lt;br /&gt;
 while [EXPR] BLOCK&lt;br /&gt;
 until [EXPR] BLOCK&lt;br /&gt;
 do BLOCK while [EXPR]&lt;br /&gt;
 do BLOCK until [EXPR]&lt;br /&gt;
 for VAR (EXPR) BLOCK&lt;br /&gt;
 for (EXPR1; EXPR2; EXPR3) BLOCK&lt;br /&gt;
*selection&lt;br /&gt;
 if (EXPR) BLOCK&lt;br /&gt;
 if (EXPR) BLOCK1 elsif (EXPR2) BLOCK2... elxe BLOCKn&lt;br /&gt;
 unless (EXPR) BLOCK&lt;br /&gt;
&lt;br /&gt;
==sträng list konverteringar==&lt;br /&gt;
 join (EXPR,LIST)&lt;br /&gt;
 @words = (&amp;quot;merry&amp;quot;, &amp;quot;go&amp;quot;, &amp;quot;round&amp;quot;);&lt;br /&gt;
 $str = join(&amp;quot;-&amp;quot;,@words);&lt;br /&gt;
&lt;br /&gt;
 split (REGEXP,EXPR)&lt;br /&gt;
 $str = &amp;quot;sys:x:3:3:sys:/dev:/bin/sh&amp;quot;;&lt;br /&gt;
 @fields = split (/:/, $str);&lt;br /&gt;
 for $rad ( @fields ){&lt;br /&gt;
     print &amp;quot;$rad\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 sub usage {&lt;br /&gt;
     print &amp;quot;use this command with optional -v&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;subrutin(15,101,38)	arguments are sent to a subroutin as a list&lt;br /&gt;
&lt;br /&gt;
==command options==&lt;br /&gt;
 use Getopt::Long;&lt;br /&gt;
 my %opts;&lt;br /&gt;
 GetOptions(\%opts,&amp;#039;v&amp;#039;,&amp;#039;g=i&amp;#039;) || &amp;amp;usage;&lt;br /&gt;
 print &amp;quot;$opts{g}\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
 sub usage {&lt;br /&gt;
     print STDERR &amp;quot;Usage: option.pl [-v][-g n]&amp;quot;;&lt;br /&gt;
     exit 1;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==globala symboltabellen==&lt;br /&gt;
 foreach my $var ( keys %main::){&lt;br /&gt;
     print &amp;quot;$var\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
==formatting.==&lt;br /&gt;
 my $rand1 = int(rand (90));&lt;br /&gt;
 my $rand2 = int(rand (10));&lt;br /&gt;
 my $rand3 = int(rand (50));&lt;br /&gt;
 printf (&amp;quot;%6d %6d %6d\n&amp;quot;,$rand1,$rand2,$rand3);&lt;br /&gt;
&lt;br /&gt;
==filehandlers==&lt;br /&gt;
 print &amp;quot;Who are you?\n&amp;quot;;&lt;br /&gt;
 my $name = &amp;lt;STDIN&amp;gt;;&lt;br /&gt;
 chomp($name);&lt;br /&gt;
 print &amp;quot;You are $name!!!\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
 STDIN   # Standard in&lt;br /&gt;
 STDOUT  # Standard out&lt;br /&gt;
 STDERR  # Standard error&lt;br /&gt;
&lt;br /&gt;
==Open a file handle for reading==&lt;br /&gt;
 open FH, &amp;#039;filename.txt&amp;#039; or die $!; # Open filehandle for reading.&lt;br /&gt;
special variables, designed to give you a way of getting at various things that Perl wants to tell you. In this case, Perl is passing on an error message from the system,&lt;br /&gt;
==Open file handle for writing==&lt;br /&gt;
 open FH, &amp;quot;&amp;gt; $filename&amp;quot; or die $!;&lt;br /&gt;
==append to existing file==&lt;br /&gt;
 open FH, &amp;quot;&amp;gt;&amp;gt; $filename&amp;quot; or die $!;&lt;br /&gt;
==open file for reading==&lt;br /&gt;
 open FH, &amp;quot;&amp;lt; $filename&amp;quot;;&lt;br /&gt;
==open directory==&lt;br /&gt;
 opendir DH, &amp;quot;.&amp;quot; or die &amp;quot;Couldn&amp;#039;t open the current directory: $!&amp;quot;;&lt;br /&gt;
Now to read each file in the directory, we use readdir on the directory handle:&lt;br /&gt;
&lt;br /&gt;
==print contents of file.==&lt;br /&gt;
 my $file = &amp;quot;/tmp/test&amp;quot;;&lt;br /&gt;
 open(IN,&amp;#039;&amp;lt;&amp;#039;,$file) || die &amp;quot;open $file failed: $!&amp;quot;;&lt;br /&gt;
 # Loopa på rader i infilen.&lt;br /&gt;
 while ( &amp;lt;IN&amp;gt; ) {&lt;br /&gt;
     print $_;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==diamond operator @ARGV==&lt;br /&gt;
 If no file handle is used with the diamond operator, Perl will examine the @ARGV special variable.&lt;br /&gt;
 If @ARGV has no elements, then  the diamond operator will read from STDIN-either from the keyboard or from a redirected file.&lt;br /&gt;
 #!/usr/bin/perl&lt;br /&gt;
 # while (&amp;lt;ARGV&amp;gt;) # Could be abbreviated to &amp;lt;&amp;gt;&lt;br /&gt;
 while (&amp;lt;&amp;gt;){&lt;br /&gt;
     print;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 This &amp;lt;...&amp;gt; construction is called the diamond operator, or readline operator:&lt;br /&gt;
&lt;br /&gt;
==list files==&lt;br /&gt;
 opendir(DIR,&amp;quot;/etc&amp;quot;);&lt;br /&gt;
 my @files = sort grep(/x/,readdir(DIR));&lt;br /&gt;
 closedir(DIR);&lt;br /&gt;
&lt;br /&gt;
==user external program==&lt;br /&gt;
 open(PING,&amp;#039;-|&amp;#039;,&amp;#039;/bin/ping -c 3 pizza&amp;#039;);&lt;br /&gt;
 while (defined(my $ping = &amp;lt;PING&amp;gt;)){&lt;br /&gt;
     print &amp;quot;$ping&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 close PROG;&lt;br /&gt;
&lt;br /&gt;
==Backslash magic==&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
\t          tab                   (HT, TAB)&lt;br /&gt;
\n          newline               (LF, NL)&lt;br /&gt;
\r          return                (CR)&lt;br /&gt;
\f          form feed             (FF)&lt;br /&gt;
\a          alarm (bell)          (BEL)&lt;br /&gt;
\e          escape (think troff)  (ESC)&lt;br /&gt;
\033        octal char (think of a PDP-11)&lt;br /&gt;
\x1B        hex char&lt;br /&gt;
\c[         control char&lt;br /&gt;
\l          lowercase next char (think vi)&lt;br /&gt;
\u          uppercase next char (think vi)&lt;br /&gt;
\L          lowercase till \E (think vi)&lt;br /&gt;
\U          uppercase till \E (think vi)&lt;br /&gt;
\E          end case modification (think vi)&lt;br /&gt;
\Q          quote (disable) pattern metacharacters till \E /\Q$pattern\E/&lt;br /&gt;
\w  Match a &amp;quot;word&amp;quot; character (alphanumeric plus &amp;quot;_&amp;quot;)&lt;br /&gt;
\W  Match a non-word character&lt;br /&gt;
\s  Match a whitespace character&lt;br /&gt;
\S  Match a non-whitespace character&lt;br /&gt;
\d  Match a digit character&lt;br /&gt;
\D  Match a non-digit character&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==keywords==&lt;br /&gt;
 Words that perl is already aware of are called keywords, and they come in several classes.&lt;br /&gt;
print is one example of the class called functions&lt;br /&gt;
==functions==&lt;br /&gt;
 hex() Convert Hexadecimal to number&lt;br /&gt;
 oct() Convert Octal to number&lt;br /&gt;
 ord() character&amp;#039;s value&lt;br /&gt;
 reverse () Reverse keypairs.&lt;br /&gt;
 keys () get key value from hash.&lt;br /&gt;
 sort () sort array&lt;br /&gt;
 values () which returns a list of all of the values in the hash&lt;br /&gt;
 each () which returns each hash entry as a key-value pair.&lt;br /&gt;
 chomp () remove final new line.&lt;br /&gt;
 length () length&lt;br /&gt;
 exists () if key exists in hash&lt;br /&gt;
 int(rand (90)) Generate a random number.&lt;br /&gt;
&lt;br /&gt;
==control keywords==&lt;br /&gt;
 There are also control keywords, such as if and else.&lt;br /&gt;
==block==&lt;br /&gt;
 We can also group together a bunch of statements into a block – which is a bit like a paragraph – by&lt;br /&gt;
surrounding them with braces: {...}&lt;br /&gt;
==number systems.==&lt;br /&gt;
&lt;br /&gt;
 print 255,&lt;br /&gt;
 octal print 0377,&lt;br /&gt;
 binary print 0b11111111,&lt;br /&gt;
 hexadecimal print 0xFF,&lt;br /&gt;
&lt;br /&gt;
==Alternative Delimiters==&lt;br /&gt;
the first acting like a single-quoted string and the second, like a double-quoted string.&lt;br /&gt;
 q// and qq//,&lt;br /&gt;
==here documents==&lt;br /&gt;
 print&amp;lt;&amp;lt;EOF;&lt;br /&gt;
 This is a here-document. It starts on the line after the two arrows,&lt;br /&gt;
 and it ends when the text following the arrows is found at the beginning&lt;br /&gt;
 of a line, like this:&lt;br /&gt;
 EOF&lt;br /&gt;
Write label with &amp;#039;EOF&amp;#039; and her text will be single quoted.&lt;br /&gt;
&lt;br /&gt;
==arithmetic Operator==&lt;br /&gt;
 #!/usr/bin/perl&lt;br /&gt;
 use warnings;&lt;br /&gt;
 print &amp;quot;21 - 25 is: &amp;quot;, 25 - 21, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 print &amp;quot;4 + 13 - 7 is: &amp;quot;, 4 + 13 - 7, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 print &amp;quot;7 * 15 is &amp;quot;, 7 * 15, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 print &amp;quot;249 / 3 is &amp;quot;, 249 / 3, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 print 3 + 7 * 15, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 print ((3 + 7) * 15);&lt;br /&gt;
&lt;br /&gt;
 21 - 25 is: 4&lt;br /&gt;
 4 + 13 - 7 is: 10&lt;br /&gt;
 7 * 15 is 105&lt;br /&gt;
 249 / 3 is 83&lt;br /&gt;
 108&lt;br /&gt;
 150&lt;br /&gt;
&lt;br /&gt;
==lazy evaluation==&lt;br /&gt;
Perl uses a technique called lazy evaluation. As soon as it knows the answer to the question, it stops working.&lt;br /&gt;
 4 &amp;gt;= 2 and print &amp;quot;Four is more than or equal to two\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
==string operators==&lt;br /&gt;
 concatenation operator   print &amp;quot;Print &amp;quot; . &amp;quot;one &amp;quot;. &amp;quot;string &amp;quot; . &amp;quot;here&amp;quot; . &amp;quot;\n&amp;quot;;&lt;br /&gt;
 repetition operator      print &amp;quot;Andreas halfface! &amp;quot;x3, &amp;quot;\n&amp;quot;; # Andreas halfface! Andreas halfface! Andreas halfface!&lt;br /&gt;
 1c # print lc(&amp;quot;FuNnY StRiNg&amp;quot;); # convert to lower case.&lt;br /&gt;
 uc # print uc(&amp;quot;FuNnY StRiNg&amp;quot;); # convert to lower case.&lt;br /&gt;
&lt;br /&gt;
==precedence operators==&lt;br /&gt;
 -&amp;gt;&lt;br /&gt;
 **&lt;br /&gt;
 ! ~ \&lt;br /&gt;
 =~ !~&lt;br /&gt;
 * / % x&lt;br /&gt;
 + - .&lt;br /&gt;
 &amp;lt;&amp;lt; &amp;gt;&amp;gt;&lt;br /&gt;
 &amp;lt; &amp;gt; &amp;lt;= &amp;gt;= lt gt le ge&lt;br /&gt;
 == != &amp;lt;=&amp;gt; eq ne cmp&lt;br /&gt;
 &amp;amp;&lt;br /&gt;
 | ^&lt;br /&gt;
 &amp;amp;&amp;amp;&lt;br /&gt;
 ||&lt;br /&gt;
 .. ...&lt;br /&gt;
 ?:&lt;br /&gt;
 , =&amp;gt;&lt;br /&gt;
 not&lt;br /&gt;
 and&lt;br /&gt;
 or xor&lt;br /&gt;
==Operating and Assigning at Once==&lt;br /&gt;
Operations, like fetching a value, modifying it, or storing it, are very common, so there&amp;#039;s a special syntax for them. Generally:&lt;br /&gt;
 $a = $a &amp;lt;some operator&amp;gt; $b;&lt;br /&gt;
can be written as&lt;br /&gt;
 $a &amp;lt;some operator&amp;gt;= $b;&lt;br /&gt;
&lt;br /&gt;
 $a = 6 * 9;&lt;br /&gt;
 print &amp;quot;Six nines are &amp;quot;, $a, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 # Six nines are 54&lt;br /&gt;
 $a += 3;&lt;br /&gt;
 print &amp;quot;Plus three is &amp;quot;, $a, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 # Plus three is 57&lt;br /&gt;
 $a /= 3;&lt;br /&gt;
 print &amp;quot;All over three is &amp;quot;, $a, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 # All over three is 19&lt;br /&gt;
&lt;br /&gt;
==operator: Autoincrement and Autodecrement==&lt;br /&gt;
 ++ and --&lt;br /&gt;
&lt;br /&gt;
 # First we set up our variables, giving the values 4 and 10 to $a and $b, respectively. :&lt;br /&gt;
 $a=4;&lt;br /&gt;
 $b=10;&lt;br /&gt;
 print &amp;quot;Our variables are &amp;quot;, $a, &amp;quot; and &amp;quot;, $b, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 # Now in the following line, the assignment happens before the increment. So $b is set to $a&amp;#039;s current value, 4 and then $a is autoincremented, becoming 5.&lt;br /&gt;
 $b=$a++;&lt;br /&gt;
 print &amp;quot;After incrementing, we have &amp;quot;, $a, &amp;quot; and &amp;quot;, $b, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 # This time, however, the incrementing takes place first. $a is now 6, and $b is set to twice that, 12.&lt;br /&gt;
 $b=++$a*2;&lt;br /&gt;
 print &amp;quot;Now, we have &amp;quot;, $a, &amp;quot; and &amp;quot;, $b, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 # Finally, $b is decremented first and becomes 11. $a is set to $b plus 4, which is 15.&lt;br /&gt;
 $a=--$b+4;&lt;br /&gt;
 print &amp;quot;Finally, we have &amp;quot;, $a, &amp;quot; and &amp;quot;, $b, &amp;quot;\n&amp;quot;;&lt;br /&gt;
==use strict==&lt;br /&gt;
 use strict to verify that we declare variables.&lt;br /&gt;
==Lexical variable==&lt;br /&gt;
 my $variable;&lt;br /&gt;
==global variable==&lt;br /&gt;
 our declare globals&lt;br /&gt;
==standard input to scripts==&lt;br /&gt;
 print &amp;quot;Please enter something interesting\n&amp;quot;;&lt;br /&gt;
 $comment = &amp;lt;STDIN&amp;gt;;&lt;br /&gt;
==array==&lt;br /&gt;
 &amp;#039;&amp;#039;&amp;#039;array&amp;#039;&amp;#039;&amp;#039; consistes of a list of &amp;#039;&amp;#039;&amp;#039;elements&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
==hash==&lt;br /&gt;
 hash. associative arrays look a bit like arrays where each element is associated with another value.&lt;br /&gt;
==define hash alternatives==&lt;br /&gt;
However, there&amp;#039;s another trick. When your lists are made up purely from single words, you can specify&lt;br /&gt;
them with the qw// operator. You can choose any paired brackets or non-word characters as your delimiters. The following lists are all identical:&lt;br /&gt;
 (&amp;#039;one&amp;#039;, &amp;#039;two&amp;#039;, &amp;#039;three&amp;#039;, &amp;#039;four&amp;#039;)&lt;br /&gt;
 qw/one two three four/&lt;br /&gt;
 qw(one two three four)&lt;br /&gt;
 qw&amp;lt;one two three four&amp;gt;&lt;br /&gt;
 qw{one two three four}&lt;br /&gt;
 qw[one two three four]&lt;br /&gt;
 qw|one two three four|&lt;br /&gt;
&lt;br /&gt;
==defining word from hash==&lt;br /&gt;
 [-1] # Count from backward from end.&lt;br /&gt;
 (19, 68, 47, 60, 53, 51, 58, 55, 47)[4, 5, 6] # &amp;#039;&amp;#039;&amp;#039;list slice&amp;#039;&amp;#039;&amp;#039;, Define words from list.&lt;br /&gt;
&lt;br /&gt;
==list allowed on left side of assignment operator.Right hand sid is build up first==&lt;br /&gt;
 ($mone, $mtwo) = (1, 3);&lt;br /&gt;
$mone is set to 1, and $mtwo to 3. But how does this work?&lt;br /&gt;
Perl allows lists on the left-hand side of an assignment operator – we say that lists are legal lvalues.&lt;br /&gt;
When we assign one list to another, the right-hand list is built up first.&lt;br /&gt;
Then perl assigns each element in turn, from the right hand side of the statement to the left.&lt;br /&gt;
So 1 is assigned to $mone, and then 3 is assigned to $mtwo.&lt;br /&gt;
==define series of elements to list==&lt;br /&gt;
 (1 .. 6)&lt;br /&gt;
 The right-hand number must, however, be higher than the left-hand one, s&lt;br /&gt;
 print &amp;quot;Counting up: &amp;quot;, (1 .. 6), &amp;quot;\n&amp;quot;;&lt;br /&gt;
 # Counting up: 123456&lt;br /&gt;
 print &amp;quot;Counting down: &amp;quot;, reverse(1 .. 6), &amp;quot;\n&amp;quot;;&lt;br /&gt;
 # Counting down: 654321&lt;br /&gt;
&lt;br /&gt;
==stringifying==&lt;br /&gt;
Forcing variables to make sense in a string is called stringifying them.&lt;br /&gt;
==scalar context &amp;amp; list context==&lt;br /&gt;
 print @array1;&lt;br /&gt;
 $scalar1 = @array1;&lt;br /&gt;
#The first line is in list context. In list context, an array returns the list of its elements.&lt;br /&gt;
# In the second line however, the assignment wants to see a single result, or scalar value, and therefore it is in scalar context. In scalar context an array returns the number of its elements.&lt;br /&gt;
&lt;br /&gt;
==change context==&lt;br /&gt;
We can force something to be in scalar context when it expects to be in list context by using the&lt;br /&gt;
scalar operator.&lt;br /&gt;
 print @array1;&lt;br /&gt;
 print scalar @array1;&lt;br /&gt;
==Do you want a scalar or array==&lt;br /&gt;
 my @days = qw(Monday Tuesday Wednesday Thursday Friday Saturday Sunday);&lt;br /&gt;
 print &amp;quot;@days[1, 3, 5]&amp;quot;, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 # Tuesday Thursday Saturday&lt;br /&gt;
 print scalar $days[3], &amp;quot;\n&amp;quot;;&lt;br /&gt;
 # Thursday&lt;br /&gt;
 print &amp;quot;@days[0..3]&amp;quot;, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 # Monday Tuesday Wednesday Thursday&lt;br /&gt;
 print &amp;quot;$days[6]&amp;quot;, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 # Sunday&lt;br /&gt;
&amp;#039;&amp;#039;The prime rule is this: the prefix represents what you want to get, not what you&amp;#039;ve got.&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;So @ represents a list of values, and $ represents a single scalar. Hence, when we&amp;#039;re&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;getting a single scalar from an array, we never prefix the variable with @ – that would&amp;#039;&amp;#039;&lt;br /&gt;
&amp;#039;&amp;#039;mean a list. A single scalar is always prefixed with a $.&amp;#039;&amp;#039;&lt;br /&gt;
==array index/array subscript==&lt;br /&gt;
 [3] We call the number in the square brackets the array index or array subscript.&lt;br /&gt;
==for loop(foreach)==&lt;br /&gt;
 my @array = qw(America Asia Europe Africa);&lt;br /&gt;
 my $element;&lt;br /&gt;
 for $element (@array) {&lt;br /&gt;
 print $element, &amp;quot;\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==for loop example==&lt;br /&gt;
 my @array=(10, 20, 30, 40);&lt;br /&gt;
 print &amp;quot;Before: @array\n&amp;quot;;&lt;br /&gt;
 for (@array) { $_ *= 2 }&lt;br /&gt;
 print &amp;quot;After: @array\n&amp;quot;;&lt;br /&gt;
The block must start with an opening brace and end with a closing brace, and the list or array that we&amp;#039;re&lt;br /&gt;
running over must be surrounded by parentheses. If we don&amp;#039;t supply an iterator variable of our own,&lt;br /&gt;
perl uses the special $_ variable, which is often used in Perl functions as a &amp;#039;default value&amp;#039;. Note that the&lt;br /&gt;
for loop doesn&amp;#039;t require a semicolon after the block.&lt;br /&gt;
So, when processing a for loop, perl makes the iterator a copy of each element of the list or array in&lt;br /&gt;
turn, and then runs the block. If the block happens to change the value of the iterator, the&lt;br /&gt;
corresponding array element changes as well. We can double each element of an array like this:&lt;br /&gt;
==push/pop==&lt;br /&gt;
 pop  We use pop @array to remove the top element from the array and it returns that element&lt;br /&gt;
 push @array, $scalar will add the scalar onto the top of the stack.&lt;br /&gt;
 # push @pileofpaper, &amp;quot;leaflet&amp;quot;, &amp;quot;bank statement&amp;quot;;&lt;br /&gt;
==Shift and Unshift==&lt;br /&gt;
 First we unshift() an element onto the array, and the element appears at the beginning of the list.&lt;br /&gt;
 We then use shift to take off the first element, ignoring what it was.&lt;br /&gt;
==sort==&lt;br /&gt;
 my @unsorted = (1, 2, 11, 24, 3, 36, 40, 4);&lt;br /&gt;
 my @string = sort { $a cmp $b } @unsorted;&lt;br /&gt;
 print &amp;quot;String sort: @string\n&amp;quot;;&lt;br /&gt;
 my @number = sort { $a &amp;lt;=&amp;gt; $b } @unsorted;&lt;br /&gt;
 print &amp;quot;Numeric sort: @number\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
 String sort: 1 11 2 24 3 36 4 40&lt;br /&gt;
 Numeric sort: 1 2 3 4 11 24 36 40&lt;br /&gt;
==Hashes==&lt;br /&gt;
Define a hash.&lt;br /&gt;
 my %where=(&lt;br /&gt;
         Gary     =&amp;gt; &amp;quot;Dallas&amp;quot;,&lt;br /&gt;
         Lucy     =&amp;gt; &amp;quot;Exeter&amp;quot;,&lt;br /&gt;
         Ian      =&amp;gt; &amp;quot;Reading&amp;quot;,&lt;br /&gt;
         Samantha =&amp;gt; &amp;quot;Oregon&amp;quot;&lt;br /&gt;
 );&lt;br /&gt;
If we want to make the relationship a little clearer, as well as highlighting the fact that we&amp;#039;re dealing with&lt;br /&gt;
a hash, we can use the =&amp;gt; operator. the =&amp;gt; operator acts like a &amp;#039;quoting comma&amp;#039;. Essentially, it&amp;#039;s a comma, but whatever appears on the left hand side of it is treated as a double-quoted string:&lt;br /&gt;
&lt;br /&gt;
 # Add to hash&lt;br /&gt;
 $where{Eva} = &amp;quot;Uxbridge&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
 # Delete from hash&lt;br /&gt;
 delete $where{Lucy};&lt;br /&gt;
&lt;br /&gt;
==convert array to hash==&lt;br /&gt;
Because hashes and arrays are both built from structures that look like lists, you can convert between them, from array to hash like this:&lt;br /&gt;
 @array = qw(Gary Dallas Lucy Exeter Ian Reading Samantha Oregon);&lt;br /&gt;
 %where = @array;&lt;br /&gt;
And then back to an array, like so:&lt;br /&gt;
 @array = %where;&lt;br /&gt;
&lt;br /&gt;
==lookup value in hash==&lt;br /&gt;
 &amp;quot;Gary lives in &amp;quot;, $where{Gary}, &amp;quot;\n&amp;quot;;&lt;br /&gt;
==iterating hashes==&lt;br /&gt;
This gives us a list of the keys (all of the scalars on the left-hand&lt;br /&gt;
  keys (%hash).&lt;br /&gt;
This will iterate on all hash keys.&lt;br /&gt;
 my %where=(&lt;br /&gt;
         Gary     =&amp;gt; &amp;quot;Dallas&amp;quot;,&lt;br /&gt;
         Lucy     =&amp;gt; &amp;quot;Exeter&amp;quot;,&lt;br /&gt;
         Ian      =&amp;gt; &amp;quot;Reading&amp;quot;,&lt;br /&gt;
         Samantha =&amp;gt; &amp;quot;Oregon&amp;quot;&lt;br /&gt;
 );&lt;br /&gt;
 for (keys %where) {&lt;br /&gt;
         print &amp;quot;$_ lives in $where{$_}\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
==if==&lt;br /&gt;
 if ( &amp;lt;some test&amp;gt; ) {&lt;br /&gt;
 &amp;lt;do something&amp;gt;&lt;br /&gt;
 }&lt;br /&gt;
If key does not exist exit.&lt;br /&gt;
 if (not exists $rates{$to}) {&lt;br /&gt;
 die &amp;quot;I don&amp;#039;t know anything about $to as a currency\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
==conditions==&lt;br /&gt;
 An empty string, &amp;quot;&amp;quot;, is false.&lt;br /&gt;
 The number zero and the string &amp;quot;0&amp;quot; are both false.&lt;br /&gt;
 An empty list, (), is false.&lt;br /&gt;
 The undefined value is false.&lt;br /&gt;
 Everything else is true.&lt;br /&gt;
==tests==&lt;br /&gt;
if variable is definee&lt;br /&gt;
 if (defined $a) {&lt;br /&gt;
 print &amp;quot;\$a has a value.\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Logical Conjunctions==&lt;br /&gt;
Join together several tests into one, by the use of the logical&lt;br /&gt;
operators. Here&amp;#039;s a summary of those:&lt;br /&gt;
 $a and $b True if both $a and $b are true.&lt;br /&gt;
 $a or $b True if either of $a or $b, or both are true.&lt;br /&gt;
 not $a True if $a is not true.&lt;br /&gt;
&lt;br /&gt;
 if (not exists $rates{$to})&lt;br /&gt;
&lt;br /&gt;
 # Another way of saying if not exist&lt;br /&gt;
 unless (exists $rates{$to}) {&lt;br /&gt;
 die &amp;quot;I don&amp;#039;t know anything about {$to} as a currency\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
==Multiple Choice==&lt;br /&gt;
else&lt;br /&gt;
 if ($password eq $guess) {&lt;br /&gt;
   print &amp;quot;Pass, friend.\n&amp;quot;;&lt;br /&gt;
 } else {&lt;br /&gt;
   die &amp;quot;Go away, imposter!\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
elseif&lt;br /&gt;
 if ( &amp;lt;condition 1&amp;gt; ) {&lt;br /&gt;
   &amp;lt;action&amp;gt;&lt;br /&gt;
 } elsif ( &amp;lt;condition 2&amp;gt; ) {&lt;br /&gt;
   &amp;lt;second action&amp;gt;&lt;br /&gt;
 } elsif ( &amp;lt;condition 3&amp;gt; ) {&lt;br /&gt;
 ...&lt;br /&gt;
 } else {&lt;br /&gt;
   &amp;lt;if all else fails&amp;gt;&lt;br /&gt;
 }&lt;br /&gt;
==last==&lt;br /&gt;
 The keyword last in the body will break out of the loop.&lt;br /&gt;
==next==&lt;br /&gt;
 If you want to skip the rest of the processing of the body, but don&amp;#039;t want to exit the loop, you can use next&lt;br /&gt;
&lt;br /&gt;
==label==&lt;br /&gt;
 A label goes before the for, while, or until of a loop, and ends with a colon.&lt;br /&gt;
 OUTER: while (&amp;lt;STDIN&amp;gt;) {&lt;br /&gt;
 chomp;&lt;br /&gt;
 INNER: for my $check (@getout) {&lt;br /&gt;
 last if $check eq $_;&lt;br /&gt;
 }&lt;br /&gt;
==metacharacters==&lt;br /&gt;
 . * ? + [ ] ( ) { } ^ $ | \&lt;br /&gt;
&lt;br /&gt;
==character classes==&lt;br /&gt;
 \d   [0-9]         Digits 0 to 9.&lt;br /&gt;
 \w   [0-9A-Za-z_]  A &amp;#039;word&amp;#039; character allowable in a Perl variable name.&lt;br /&gt;
 \s   [ \t\n\r]     A whitespace character that is, a space, a tab, a newline or a return.&lt;br /&gt;
 \D   [^0-9]        Any non-digit.&lt;br /&gt;
 \W   [^0-9A-Za-z_] A non-&amp;#039;word&amp;#039; character.&lt;br /&gt;
 \S   [^ \t\n\r]    A non-blank character.&lt;br /&gt;
 \b                 Wordboundry&lt;br /&gt;
==posix==&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
 [[:alpha:]]   [a-zA-Z]       An alphabetic character.&lt;br /&gt;
 [[:alnum:]]   [0-9A-Za-z]    An alphabetic or numeric character.&lt;br /&gt;
 [[:digit:]]   \d             A digit, 0-9.&lt;br /&gt;
 [[:lower:]]   [a-z]          A lower case letter.&lt;br /&gt;
 [[:upper:]]   [A-Z]          An upper case letter.&lt;br /&gt;
 [[:punct:]]   [!&amp;quot;#$%&amp;amp;&amp;#039;()*+,-./:;&amp;lt;=&amp;gt;?@\[\\\]^_`{|}~]   A punctuation character – note the escaped characters [, \, and ]&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
==regexp matching==&lt;br /&gt;
#The regular expression engine starts as soon as it can, grabs as much as it can, then tries to finish as soon as it can, while taking the first decision available to it.&lt;br /&gt;
 &amp;#039;ye(s|t)&amp;#039;   The text matches the pattern &amp;#039;ye(s|t)&amp;#039;&lt;br /&gt;
 (andreas)?  Match andreas or nothing.&lt;br /&gt;
&lt;br /&gt;
==quantifiers==&lt;br /&gt;
 ?   One or none.&lt;br /&gt;
 +   One or more.&lt;br /&gt;
 *   Zero or unlimited&lt;br /&gt;
 \s{2,3}  Space 2 to 3 times.&lt;br /&gt;
 {2,} &amp;#039;2 or more&amp;#039;&lt;br /&gt;
 {,3} &amp;#039;3 or fewer&amp;#039;&lt;br /&gt;
 {9}   Match 9 times.&lt;br /&gt;
==backreference==&lt;br /&gt;
 Each time it sees a set of parentheses, it copies the matched text inside into a numbered variable –&lt;br /&gt;
 the first matched group goes in $1, the second group in $2, and so on. By looking at these variables, which we call the backreference variables,&lt;br /&gt;
==greedy==&lt;br /&gt;
 (.*?)   Search for any key zero or more times. Match as little as possible.(non greedy)&lt;br /&gt;
==substitution==&lt;br /&gt;
 s/regexp/substitute/     Substitute first occurance of regexp with substitute&lt;br /&gt;
 s/regexp/substitute/g    Substitute regexp with substitute globally.&lt;br /&gt;
 s/(\w+)\s+(\w+)/$2 $1/;  Substitute with backreference. Swap the first two words.&lt;br /&gt;
 s{old text}{new text}g;  Changed delimiters. Pair delimiters.&lt;br /&gt;
 s{old text}&lt;br /&gt;
 {new text}g;             You can have new line or space between delimiters.&lt;br /&gt;
==regexp modifiers==&lt;br /&gt;
 /i   Case insensitive&lt;br /&gt;
 /m   treat the string as multiple lines.&lt;br /&gt;
 /s   treat the string as a single line.&lt;br /&gt;
 /g   match multiple times.&lt;br /&gt;
 /x   allow the use of whitespace and comments inside a match.&lt;br /&gt;
==split==&lt;br /&gt;
 my @fields = split /:/, $passwd;   Create array with each field of passwd&lt;br /&gt;
==join==&lt;br /&gt;
 my $passwd2 = join &amp;quot;#&amp;quot;, @fields;&lt;br /&gt;
==transliteration==&lt;br /&gt;
 $string =~ tr/0-9/a-j/;   &amp;quot;2011064&amp;quot; into &amp;quot;cabbage&amp;quot;&lt;br /&gt;
 $string =~ tr/ //d;       Remove spaces.&lt;br /&gt;
==inline modifiers==&lt;br /&gt;
===inline comments===&lt;br /&gt;
 (?#)   Example: /^Today&amp;#039;s (?# This is ignored, by the way)date:/&lt;br /&gt;
 (?i)one way to do it!&lt;br /&gt;
===inline case insensetive===&lt;br /&gt;
 (?i)one way to do it!&lt;br /&gt;
===Disable backreference===&lt;br /&gt;
 /(?:X-)?Topic: (\w+)/;   # Disable first back reference.&lt;br /&gt;
===Lookaheads and Lookbehinds===&lt;br /&gt;
 s/fish cake/cream cake/   # These do the same thing.&lt;br /&gt;
 /fish(?= cake)/           # These do the same thing.&lt;br /&gt;
==input record separator==&lt;br /&gt;
 $/ is called the &amp;#039;input record separator&amp;#039;&lt;br /&gt;
 $/ = &amp;quot;\n%\n&amp;quot;;   # Record separator is now an empty %.&lt;br /&gt;
 $/ = undef;     # Undefine input record separator.&lt;br /&gt;
 What the star – or, to give it its proper name, the glob – does is actually very subtle:&lt;br /&gt;
&lt;br /&gt;
==glob *==&lt;br /&gt;
 *a = *b makes everything called a – that is $a, @a, %a, and the filehandle called a –&lt;br /&gt;
 into an alias for everything called b. This is more than just setting them to the same&lt;br /&gt;
 value – it makes them the same thing&lt;br /&gt;
==select==&lt;br /&gt;
 select FILEHANDLE; #  change the default filehandle&lt;br /&gt;
==buffering==&lt;br /&gt;
 $| = 1; # Perl turns off buffering for the currently selected filehandle.&lt;br /&gt;
==Opening Pipes==&lt;br /&gt;
 open LYNX, &amp;quot;lynx –source http://www.perl.com/ |&amp;quot; or die &amp;quot;Can&amp;#039;t open lynx: $!&amp;quot;;  # The pipe symbol | at the end of the string tells Perl to run the command and collect the output.&lt;br /&gt;
==file tests==&lt;br /&gt;
 if (-e &amp;quot;somefile.dat&amp;quot;) {...}   # If file exists.&lt;br /&gt;
&lt;br /&gt;
 -e True if the file exists.&lt;br /&gt;
 -f True if the file is a plain file – not a directory.&lt;br /&gt;
 -d True if the file is a directory.&lt;br /&gt;
 -z True if the file has zero size.&lt;br /&gt;
 -s True if the file has nonzero size – returns size of file in bytes.&lt;br /&gt;
 -r True if the file is readable by you.&lt;br /&gt;
 -w True if the file is writable by you.&lt;br /&gt;
 -x True if the file is executable by you.&lt;br /&gt;
 -o True if the file is owned by you.&lt;br /&gt;
==anonymous references==&lt;br /&gt;
 Anonymous References&lt;br /&gt;
 To get an array reference instead of an array, use square brackets [] instead of parentheses.&lt;br /&gt;
 To get a hash reference instead of a hash, use curly braces {} instead of parentheses.&lt;br /&gt;
&lt;br /&gt;
So, referring to our examples above, instead of doing this:&lt;br /&gt;
 my @array = (1, 2, 3, 4, 5);&lt;br /&gt;
 my $array_r = \@array;&lt;br /&gt;
we can go straight to an array reference like this:&lt;br /&gt;
 my $array_r = [1, 2, 3, 4, 5];&lt;br /&gt;
Likewise, to get a hash reference, instead of doing this:&lt;br /&gt;
 my %hash = ( apple =&amp;gt; &amp;quot;pomme&amp;quot;, pear =&amp;gt; &amp;quot;poire&amp;quot; );&lt;br /&gt;
 my $hash_r = \%hash;&lt;br /&gt;
we say:&lt;br /&gt;
 my $hash_r = { apple =&amp;gt; &amp;quot;pomme&amp;quot;, pear =&amp;gt; &amp;quot;poire&amp;quot; };&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 my @array = ( 100,200,[ 2,4,[ 1,2,[ 10,20,30,40,50 ],3,4 ],6,8 ],300,400 );&lt;br /&gt;
&lt;br /&gt;
==notation shorthands==&lt;br /&gt;
 Instead of ${$ref}, we can say $ref-&amp;gt;&lt;br /&gt;
==matrices==&lt;br /&gt;
 $array[$row]-&amp;gt;[$column] # chessboard matrics&lt;br /&gt;
 $array[0]-&amp;gt;[0]          # First row first column.&lt;br /&gt;
==Autovivification==&lt;br /&gt;
If we assign values to a reference, perl will automatically create all appropriate references necessary to make it work.&lt;br /&gt;
 my $ref;&lt;br /&gt;
 $ref-&amp;gt;{UK}-&amp;gt;{England}-&amp;gt;{Oxford}-&amp;gt;[1999]-&amp;gt;{Population} = 500000;&lt;br /&gt;
Is equal to making.&lt;br /&gt;
 $ref = {};&lt;br /&gt;
 $ref-&amp;gt;{UK} = {};&lt;br /&gt;
 $ref-&amp;gt;{UK}-&amp;gt;{England} = {};&lt;br /&gt;
 $ref-&amp;gt;{UK}-&amp;gt;{England}-&amp;gt;{Oxford} = [];&lt;br /&gt;
 $ref-&amp;gt;{UK}-&amp;gt;{England}-&amp;gt;{Oxford}-&amp;gt;[1999] = {};&lt;br /&gt;
 $ref-&amp;gt;{UK}-&amp;gt;{England}-&amp;gt;{Oxford}-&amp;gt;[1999]-&amp;gt;{Population} = 500000;&lt;br /&gt;
&lt;br /&gt;
==links==&lt;br /&gt;
[[Category:Applications]]&lt;br /&gt;
[[Category:Unix]]&lt;/div&gt;</summary>
		<author><name>Ekaanbj</name></author>
	</entry>
</feed>