Buscar

mishin perlcheat

Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original

perlcheat Cheat Sheet
by Nikolay Mishin (mishin) via cheatography.com/1008/cs/396/
About Perlcheat
AUTHOR Juerd Waalboer, with the
help of many Perl Monks.
the original PM
post
http:/ ​/pe ​rlm ​onk ​s.o ​rg/ ​?
no ​de_ ​id= ​216602
Damian
Conway's Perl 6
version
http:/ ​/pe ​rlm ​onk ​s.o ​rg/ ​?
no ​de_ ​id= ​238031
home of the Perl
Cheat Sheet
http:/ ​/ju ​erd.nl ​/si ​te.p ​lp ​/pe ​rlche
at
CONTEXTS
void
scalar
list
SIGILS
$scalar
@array
%hash
&sub
*glob
ARRAYS ​,HASHES
 ARRAYS HASHES
whole: @array %hash
slice: @array[0, 2] @hash{'a', 'b'}
element: $array[0] $hash{'a'}
 
SCALAR VALUES
number, string, reference, glob, undef
SYNTAX
for (LIST) { }, for (a;b;c) { }
while ( ) { }, until ( ) { }
if ( ) { } elsif ( ) { } else { }
unless ( ) { } elsif ( ) { } else { }
for equals foreach (ALWAYS)
LINKS
Search the CPAN - metacp ​an.org https: ​//m ​et
a ​cpa ​n.org
Perl Weekly http:/ ​/pe ​rlw ​
eek ​ly.c ​om ​/‐
la ​tes ​t.html
Perl ​Monks - The Monastery
Gates
http:/ ​/ww ​w
.p ​erl ​mon ​k
s.org/
What's happening in the world of
Perl progra ​mming, including Perl
5, Perl 6, the CPAN and Parrot?
http:/ ​/pe ​rlb ​
uzz.com/
The Compre ​hensive Perl Archive
Network - www.cp ​an.org
http:/ ​/cp ​an.
org
News and views of the Perl
progra ​mming language
http:/ ​/ww ​w
.p ​erl.com/
Perl progra ​mming docume ​ntation
- perldo ​c.p ​erl.org
http:/ ​/pe ​rld ​
oc.p ​er ​l.org‐
/
 
LINKS (cont)
Perl Confer ​ences,
YAPCs,
Workshops, and
Hackathons
http:/ ​/ww ​w.y ​apc.org/
Perl 6 http:/ ​/pe ​rl6.org/
Perl 6 Tablet 2 -
Basic Syntax
http:/ ​/ta ​ble ​ts.p ​er ​l6.o ​rg ​/ta ​bl
e ​t-2 ​-ba ​sic ​-sy ​nta ​x.html
Learn Perl -
learn.p ​er ​l.org
http:/ ​/le ​arn.pe ​rl.org/
Perl - Download http:/ ​/ww ​w.p ​erl.or ​g/g ​et.ht
ml
The Perl.org Online
Library
http:/ ​/ww ​w.p ​erl.or ​g/b ​ook ​s
/l ​ibr ​ary.html
Books and More
(Videos)
http:/ ​/ww ​w.p ​erl.or ​g/m ​edi ​a
.html
Padre, the Perl IDE http:/ ​/pa ​dre.pe ​rli ​de.org/
perlcheat http:/ ​/pe ​rld ​oc.p ​er ​l.o ​rg/ ​per ​l
ch ​eat.html
Gabor Szabo Perl
Trainer and
develo ​per
http:/ ​/sz ​abg ​ab.com/
Perl,Perl
Monger ​s,M ​ong ​ers ​,U
ser Group, ​Meeting
http:/ ​/pm.org
Facebook vs
Google+ for Perl
projects
http:/ ​/sz ​abg ​ab.c ​om ​/fa ​ceb ​o
ok ​-vs ​-go ​ogl ​e-p ​lus ​-fo ​r-
p ​erl ​-pr ​oje ​cts.html
By Nikolay Mishin (mishin)
cheatography.com/mishin/
mishin.narod.ru
 
Published 1st June, 2012.
Last updated 5th June, 2014.
Page 1 of 5.
 
Sponsored by Readability-Score.com
Measure your website readability!
https://readability-score.com
perlcheat Cheat Sheet
by Nikolay Mishin (mishin) via cheatography.com/1008/cs/396/
LINKS (cont)
Lections about Per
from Gabor Szabo
http:/ ​/ww ​w.y ​out ​ube.co ​m/
r ​esu ​lts ​?
se ​arc ​h_q ​uer ​y=g ​abo ​r+pe
rl
mod_perl world http:/ ​/pe ​rl.a ​pa ​che.org
Interp ​reted
Languages: PHP,
Perl, Python, Ruby
(Sheet One)
http:/ ​/hy ​per ​pol ​ygl ​ot.o ​rg ​/s
c ​ripting
Moose - A
postmodern object
system for Perl
http:/ ​/mo ​ose.ii ​nte ​rac ​tiv ​e.
com/
Perl Training
Australia - Perl Tips
http:/ ​/pe ​rlt ​rai ​nin ​g.c ​om.a ​u
/ ​tips/
Basic Perl (Ynon
Perek | An Amazing
Learning
Experi ​ence) , super
http:/ ​/yn ​onp ​ere ​k.c ​om/ ​cou ​
rse ​s/b ​asi ​c-p ​erl.html
Perl Questions -
Stack Overflow
http:/ ​/st ​ack ​ove ​rfl ​ow.c ​om ​/
qu ​est ​ion ​s/t ​agg ​ed/ ​per ​l?
s ​ort ​=fa ​q& ​pag ​esi ​ze=15
Perl - Cheat sheets
Collection
http:/ ​/pe ​rl4 ​eve ​ryt ​hin ​g.b ​lo
g ​spo ​t.c ​om/ ​201 ​0/1 ​2/p ​erl ​-
ch ​eat ​-sh ​eet ​s-
c ​oll ​ect ​ion.html
comp ​lete, working
examples of good
Perl code
http:/ ​/pe ​rlm ​eme.or ​g/s ​tar ​t
_h ​ere ​/in ​dex.html
 
LINKS (cont)
Perl
Progra ​mming
Tutorials
http:/ ​/ww ​w.d ​evs ​hed.co ​m/c ​/b/ ​Pe
rl/
Video from
UniverTV
http:/ ​/un ​ive ​rtv.ru ​/se ​arc ​h/? ​txt ​=pe ​
rl&x= ​0&y=0
FAQ по perl и
програ ​мми ​ро
ванию для
web
http:/ ​/ww ​w.c ​ybe ​rgu ​ru.r ​u/ ​web ​/w
e ​b-p ​rog ​ram ​min ​g/p ​erl ​-we ​b-
p ​rog ​ram ​min ​g-f ​aq- ​pag ​e2.html
FAQ PERL
Agava
http:/ ​/ho ​sti ​ng.a ​ga ​va.r ​u/ ​faq ​/te ​ch/ ​d
oc ​s/p ​erl.shtml
Modern ​::Perl
Modern ​::Perl
enable all of the features of Modern Perl with
one import
Toolkit
use Toolkit; and put all your favorite modules
in a file: > cat
$PERL5 ​LIB ​/To ​olk ​it/ ​Mac ​ros ​/AL ​WAY ​S/M ​odules
use strict; use warnings; use Carp; use
Smart: ​:Co ​mments;
 
Modern ​::Perl (cont)
use common ​::s ​ense;
supposed to be the same, with much lower
memory usage, as: # # use strict qw(vars
subs); # use feature qw(say state switch); #
no warnings; # use warnings qw(FATAL
closed threads internal debugging pack
substr malloc # unopened portable
prototype inplace io pipe unpack regexp #
deprecated exiting glob digit printf utf8 layer
# reserved parent ​hesis taint closure
semico ​lon); # no warnings qw(exec
newline);
latest
There is latest, which is no longer the latest.
Demons ​trates part of the naming problem.
uni::perl
Also, uni::perl which adds enabling unicode
part of the mix.
ToolSet
ToolSet offers a subset of Toolkit's abilities,
but without source filters.
Moose
I'll include Moose here, since it
automa ​tically adds strict and warnings to
the calling package.
Acme:: ​Ver ​y:: ​Mod ​ern ​::Perl
Using this module, you'll get Modern ​::Perl,
Toolkit, latest, uni::perl, perl5i, and
common ​::sense with just one simple line.
By Nikolay Mishin (mishin)
cheatography.com/mishin/
mishin.narod.ru
 
Published 1st June, 2012.
Last updated 5th June, 2014.
Page 2 of 5.
 
Sponsored by Readability-Score.com
Measure your website readability!
https://readability-score.com
perlcheat Cheat Sheet
by Nikolay Mishin (mishin) via cheatography.com/1008/cs/396/
Modern ​::Perl (cont)
Source
http:/ ​/st ​ack ​ove ​rfl ​ow.c ​om ​/qu ​est ​ion ​s/1 ​625 ​839 ​/sh ​
oul ​d-i ​-us ​e-c ​omm ​ons ​ens ​e-o ​r-j ​ust ​-st ​ick ​-
wi ​th- ​use ​-st ​ric ​t-a ​nd- ​use ​-wa ​rnings
REGEX METACHARS
^ string begin
$ str. end (before \n)
+ one or more
* zero or more
? zero or one
{3,7} repeat in range
() capture
(?:) no capture
[] character class
| altern ​ation
\b word boundary
\z string end
http:/ ​/pe ​rld ​oc.p ​er ​l.o ​rg/ ​per ​lre.html
Perl image
REGEX CHARCL ​ASSES
. [^\n]
\s [\x20 ​\f\t ​\r\n]
\w [A-Za- ​z0-9_]
\d [0-9]
\S, \W and \D negate
 
REGEX MODIFIERS
/i case insens.
/m line based ^$
/s . includes \n
/x ign. wh.space
/g global
\Q quote (disable) pattern metach ​ara ​cters till
\E
\E end either case modifi ​cation or quoted
section, think vi
FUNCTION RETURN LISTS
stat localtime caller
0 dev 0 second 0 package
1 ino 1 minute 1 filename
2 mode 2 hour 2 line
3 nlink 3 day 3 subroutine
4 uid 4 month-1 4 hasargs
5 gid 5 year-1900 5 wantarray
6 rdev 6 weekday 6 evaltext
7 size 7 yearday 7 is_require
8 atime 8 is_dst 8 hints
 
FUNCTION RETURN LISTS (cont)
9
mtime
 9
bitmask
10
ctime
just use
11
blksz
POSIX:: 3..9
only
12
blcks
strftime!
http:/ ​/do ​cst ​ore.mi ​k.u ​a/o ​rel ​ly/ ​p
er ​l/p ​rog ​3/c ​h32 ​_36.htm
with
EXPR
opendir & grep:
opendi ​r(D ​IR, ​" ​$SC ​AND ​ATA ​");
@files = sort(g ​rep ​(/[ ​0-9 ​]\.[0 ​-
9] ​\- ​/,r ​ead ​dir ​(DI ​R)));
closed ​ir( ​DIR);
hash iteration:
while (($key ​,$val) = each (%hash)) { }
getopt
use Getopt ​::Std;
%optio ​ns=();
getopt ​s("h ​e:f ​:s: ​SD: ​u:F ​:", ​\%op ​tions);
if ($opti ​ons{h}) { &u ​sage(); }
http:/ ​/ww ​w.p ​erl ​how ​to.c ​om ​/pa ​rsi ​ng_ ​com ​man ​d_l ​in
e ​_pa ​ram ​ete ​rs_ ​wit ​h_g ​eto ​pt_long
http:/ ​/ww ​w.p ​erl ​mon ​ks.o ​rg ​/?n ​ode ​_id ​=455158
http:/ ​/ap ​law ​ren ​ce.c ​om ​/Un ​ix/ ​per ​lge ​top ​ts.html
http:/ ​/ww ​w.c ​s.m ​cgi ​ll.c ​a/ ​~ab ​atk ​o/c ​omp ​ute ​rs/ ​pro ​gr
a ​mmi ​ng/ ​per ​l/h ​owt ​o/g ​etopts/
http:/ ​/pe ​rl.f ​in ​d-i ​nfo.ru ​/pe ​rl/ ​015 ​/in ​ter ​fac ​e/1.htm
By Nikolay Mishin (mishin)
cheatography.com/mishin/
mishin.narod.ru
 
Published 1st June, 2012.
Last updated 5th June, 2014.
Page 3 of 5.
 
Sponsored by Readability-Score.com
Measure your website readability!
https://readability-score.com
perlcheat Cheat Sheet
by Nikolay Mishin (mishin) via cheatography.com/1008/cs/396/
Perl IDE
source http:/ ​/ww ​w.p ​erl ​ide.org/
Padre http:/ ​/pa ​dre.pe ​rli ​de.org/ The Perl
Applic ​ation Develo ​pment and
Refact ​oring Enviro ​nment (written in
Perl 5)
Ecli ​pse with the EPIC plugin
http:/ ​/ww ​w.e ​pic ​-id ​e.org/ or with
Perlipse
http:/ ​/co ​de.g ​oo ​gle.co ​m/p ​/pe ​rlipse/
using dltk
Acti ​veS ​
tate
propri ​etary Komodo IDE
http:/ ​/ww ​w.a ​cti ​ves ​tat ​e.c ​om/ ​Pro ​duc ​ts/ ​k
om ​odo ​_ide/ or free Komodo Edit
http:/ ​/ww ​w.a ​cti ​ves ​tat ​e.c ​om/ ​Pro ​duc ​ts/ ​k
om ​odo ​_id ​e/k ​omo ​do_ ​edi ​t.mhtml
Kephra http:/ ​/ke ​phr ​a.s ​our ​cef ​org ​e.net
Progra ​mmers Editor along perl-like
Paradigms, written in Perl
Gvim www.vi ​m.org with Perl support
http:/ ​/ww ​w.v ​im.o ​rg ​/sc ​rip ​ts/ ​scr ​ipt.ph ​p?
s ​cri ​pt_ ​id=556
 
Perl IDE (cont)
Emacs www.gn ​u.o ​rg/ ​sof ​twa ​re/ ​emacs/ with
CPerl Mode
http:/ ​/ww ​w.e ​mac ​swi ​ki.o ​rg ​/cg ​i-
b ​in/ ​wik ​i/C ​Per ​lMode
Perl
Develo ​
pment
Tools
http:/ ​/ww ​w.p ​erl ​mon ​ks.o ​rg ​/?
n ​ode ​=Pe ​rl% ​20D ​eve ​lop ​men ​t%2 ​0Tools
Escape sequences
\t tab (HT, TAB)
\n newline (LF, NL)
\r return (CR)
\f form feed (FF)
\a alarm (bell) (BEL)
\e escape (think troff) (ESC)
\cK control char (example: VT)
\x{}, \x00 character whose ordinal is the
given hexade ​cimal number
\N{name} amed Unicode character or
character sequence
\N{U+263D} Unicode character (example:
FIRST QUARTER MOON)
\o{}, \000 character whose ordinal is the
given octal number
\l lowercase next char (think vi)
\u uppercase next char (think vi)
\L lowercase till \E (think vi)
\U uppercase till \E (think vi)
 
Escape sequences (cont)
\Q quote (disable) pattern metach ​ara ​cters till
\E
\E end either case modifi ​cation or quoted
section, think vi
REFERENCES
\ $$foo[1] ==
references $foo->[1]
$@%&* $$foo{ ​bar}==
derefe ​rence $foo-> ​{bar}
{} ${$$fo ​o[1 ​]}[2]==
anon. hashref $foo-> ​[1] ​->[2]
\() ${$$fo ​o[1 ​]}[2]==
list of refs $foo-> ​[1][2]
SPECIAL VARIABLES
$_ default variable
$0 program name
$/ input separator
$\ output separator
$| autoflush
$! sys/li ​bcall error
$@ eval error
$$ process ID
$. line number
@ARGV command line args
@INC include paths
@_ subroutine args
%ENV enviro ​nment
By Nikolay Mishin (mishin)
cheatography.com/mishin/
mishin.narod.ru
 
Published 1st June, 2012.
Last updated 5th June, 2014.
Page 4 of 5.
 
Sponsored by Readability-Score.com
Measure your website readability!
https://readability-score.com
perlcheat Cheat Sheet
by Nikolay Mishin (mishin) via cheatography.com/1008/cs/396/
NUMBERS vs STRINGS
NUMBERS STRINGS
= =
. .
== != eq ne
< > <= >= lt gt le ge
<=> cmp
DO
use Modern ​::Perl;
use strict;
use warnings;
my $var;
open() or die $!;
use Modules;
DON'T
" ​$fo ​o"
$$vari ​abl ​e_name
$user ​input
/$user ​input/
capita ​lizing:
word: $foo = ucfirst lc $foo;
each word: $foo =~ s/(\w+ ​)/ ​\u\L ​$1/g;
refere ​ncing a subrou ​tine:
$SUBNAME = " ​jun ​k";
&$ ​SUB ​NAM ​E(@ ​PAR ​AME ​TERS);
 
foreach:
foreach $FILE (@FILES) { }
OPERATOR PRECEDENCE
->
++ --
**
! ~ \ u+ u-
=~ !~
* / % x
+ - .
<< >>
named uops
< > <= >= lt gt le ge
== != <=> eq ne cmp
&
| ^
&&
||
.. ...
?:
= += -= *= etc.
, =>
list ops
not
and
or xor
 
Link to perl cheat
perlcheat
http:/ ​/ww ​w.c ​hea ​tog ​rap ​hy.c ​om ​/mi ​shi ​n/c ​hea ​t-
s ​hee ​ts/ ​per ​lcheat/
perl-r ​efe ​ren ​ce-card
http:/ ​/ww ​w.c ​hea ​tog ​rap ​hy.c ​om ​/mi ​shi ​n/c ​hea ​t-
s ​hee ​ts/ ​per ​l-r ​efe ​ren ​ce- ​card/
20-kil ​ler ​-pe ​rl- ​pro ​gra ​mmi ​ng-tips
http:/ ​/ww ​w.c ​hea ​tog ​rap ​hy.c ​om ​/mi ​shi ​n/c ​hea ​t-
s ​hee ​ts/ ​20- ​kil ​ler ​-pe ​rl- ​pro ​gra ​mmi ​ng- ​tip ​s-
f ​or- ​beg ​inners/
By Nikolay Mishin (mishin)
cheatography.com/mishin/
mishin.narod.ru
 
Published 1st June, 2012.
Last updated 5th June, 2014.
Page 5 of 5.
 
Sponsored by Readability-Score.com
Measure your website readability!
https://readability-score.com
	perlcheat Cheat Sheet - Page 1
	About Perlcheat
	SCALAR VALUES
	SYNTAX
	CONTEXTS
	LINKS
	SIGILS
	ARRAYS­,HASHES
	perlcheat Cheat Sheet - Page 2
	Modern­::Perl
	perlcheat Cheat Sheet - Page 3
	REGEX MODIFIERS
	REGEX METACHARS
	opendir & grep:
	FUNCTION RETURN LISTS
	hash iteration:
	getopt
	Perl image
	REGEX CHARCL­ASSES
	perlcheat Cheat Sheet - Page 4
	Perl IDE
	REFERENCES
	Escape sequences
	SPECIAL VARIABLES
	perlcheat Cheat Sheet - Page 5
	NUMBERS vs STRINGS
	foreach:
	Link to perl cheat
	OPERATOR PRECEDENCE
	DO
	DON'T
	capita­lizing:
	refere­ncing a subrou­tine:

Teste o Premium para desbloquear

Aproveite todos os benefícios por 3 dias sem pagar! 😉
Já tem cadastro?

Outros materiais