Perlcheat Cheat Sheet by Nikolay Mishin (Mishin) Via Cheatography.Com/1008/Cs/396
Total Page:16
File Type:pdf, Size:1020Kb
perlcheat Cheat Sheet by Nikolay Mishin (mishin) via cheatography.com/1008/cs/396/ About Perlcheat REGEX METACHARS Escape sequences AUTHOR Juerd Waalboer, with the help ^ string begin \t tab (HT, TAB) of many Perl Monks. $ str. end (before \n) \n newline (LF, NL) the original PM http://perlmonks.org/?node_id= + one or more \r return (CR) post 216602 * zero or more \f form feed (FF) Damian Conway's http://perlmonks.org/?node_id= ? zero or one \a alarm (bell) (BEL) Perl 6 version 238031 {3,7} repeat in range \e escape (think troff) (ESC) home of the Perl http://juerd.nl/site.plp/perlcheat Cheat Sheet () capture \cK control char (example: VT) (?:) no capture \x{}, \x00 character whose ordinal is the given CONTEXTS [] character class hexadecimal number void | alternation \N{name} amed Unicode character or character sequence scalar \b word boundary \N{U+263D} Unicode character (example: FIRST list \z string end QUARTER MOON) http://perldoc.perl.org/perlre.html \o{}, \000 character whose ordinal is the given SIGILS octal number $scalar Perl image \l lowercase next char (think vi) @array \u uppercase next char (think vi) %hash \L lowercase till \E (think vi) &sub \U uppercase till \E (think vi) *glob \Q quote (disable) pattern metacharacters till \E ARRAYS,HASHES \E end either case modification or quoted ARRAYS HASHES section, think vi whole: @array %hash slice: @array[0, 2] @hash{'a', 'b'} REFERENCES element: $array[0] $hash{'a'} \ $$foo[1] == references $foo->[1] SCALAR VALUES $@%&* $$foo{bar}== number, string, reference, glob, undef dereference $foo->{bar} {} ${$$foo[1]}[2]== SYNTAX REGEX CHARCLASSES anon. hashref $foo->[1]->[2] for (LIST) { }, for (a;b;c) { } . [^\n] \() ${$$foo[1]}[2]== while ( ) { }, until ( ) { } \s [\x20\f\t\r\n] list of refs $foo->[1][2] \w [A-Za-z0-9_] if ( ) { } elsif ( ) { } else { } \d [0-9] unless ( ) { } elsif ( ) { } else { } SPECIAL VARIABLES \S, \W and \D negate for equals foreach (ALWAYS) $_ default variable $0 program name LINKS REGEX MODIFIERS $/ input separator Search the CPAN - metacp https://metacpan.org /i case insens. $\ output separator an.org /m line based ^$ $| autoflush Perl Weekly http://perlweekly.com/la /s . includes \n $! sys/libcall error test.html /x ign. wh.space http://www.perlmon $@ eval error PerlMonks - The /g global Monastery Gates ks.org/ $$ process ID \Q quote (disable) pattern metacharacters till \E What's happening in the http://perlbuzz.com/ $. line number \E end either case modification or quoted section, world of Perl programming, @ARGV command line args think vi including Perl 5, Perl 6, the @INC include paths CPAN and Parrot? FUNCTION RETURN LISTS @_ subroutine args The Comprehensive Perl http://cpan.org Archive Network - www.cp stat localtime caller %ENV environment an.org 0 dev 0 second 0 package NUMBERS vs STRINGS News and views of the Perl http://www.perl.com/ 1 ino 1 minute 1 filename programming language 2 2 hour 2 line NUMBERS STRINGS Perl programming docume http://perldoc.perl.org/ mode = = ntation - perldoc.perl.org ntation - perldoc.perl.org 3 3 day 3 . Perl Conferences, YAPCs, http://www.yapc.org/ nlink subroutine == != eq ne Workshops, and 4 uid 4 month-1 4 hasargs Hackathons < > <= >= lt gt le ge 5 gid 5 year-1900 5 Perl 6 http://perl6.org/ <=> cmp wantarray Perl 6 Tablet 2 - Basic http://tablets.perl6.org/ta 6 6 weekday 6 evaltext Syntax blet-2-basic-syntax.html DO rdev Learn Perl - learn.perl.org http://learn.perl.org/ use Modern::Perl; 7 size 7 yearday 7 use strict; Perl - Download http://www.perl.org/g is_require et.html use warnings; 8 8 is_dst 8 hints The Perl.org Online Library http://www.perl.org/b atime my $var; ooks/library.html 9 9 bitmask open() or die $!; Books and More (Videos) http://www.perl.org/medi mtime use Modules; a.html 10 just use Padre, the Perl IDE http://padre.perlide.org/ ctime DON'T perlcheat http://perldoc.perl.org/ 11 POSIX:: 3..9 only "$foo" perlcheat.html blksz $$variable_name Gabor Szabo Perl Trainer http://szabgab.com/ 12 strftime! http://docstore.mik.ua/o with EXPR `$userinput` and developer blcks relly/perl/prog3/ch32_36.htm Perl,Perl Mongers,Mongers http://pm.org /$userinput/ ,User Group,Meeting opendir & grep: capitalizing: Facebook vs Google+ for http://szabgab.com/fa opendir(DIR,"$SCANDATA"); Perl projects cebook-vs-google-plus- @files = sort(grep(/[0-9]\.[0-9] \-/,readdir(DIR))); word: $foo = ucfirst lc $foo; for-perl-projects.html closedir(DIR); each word: $foo =~ s/(\w+)/\u\L$1/g; Lections about Per from http://www.youtube.co Gabor Szabo m/results?search_quer hash iteration: referencing a subroutine: y=gabor+perl while (($key,$val) = each (%hash)) { } $SUBNAME = "junk"; mod_perl world http://perl.apache.org &$SUBNAME(@PARAMETERS); Interpreted Languages: http://hyperpolyglot.org getopt PHP, Perl, Python, Ruby /scripting foreach: use Getopt::Std; (Sheet One) %options=(); foreach $FILE (@FILES) { } Moose - A postmodern http://moose.iinteractiv getopts("he:f:s:SD:u:F:",\%options); object system for Perl e.com/ if ($options{h}) { &usage(); } OPERATOR PRECEDENCE Perl Training Australia - http://perltraining.com.a -> Perl Tips u/tips/ http://www.perlhowto.com/parsing_command_line_pa ++ -- Basic Perl (Ynon Perek | http://ynonperek.com/ rameters_with_getopt_long An Amazing Learning courses/basic-perl.html http://www.perlmonks.org/?node_id=455158 ** http://aplawrence.com/Unix/perlgetopts.html Experience) , super ! ~ \ u+ u- http://www.cs.mcgill.ca/~abatko/computers/programmi Perl Questions - Stack http://stackoverflow.com ng/perl/howto/getopts/ =~ !~ Overflow /questions/tagged/perl? http://perl.find-info.ru/perl/015/interface/1.htm * / % x sort=faq&pagesize=15 + - . Perl - Cheat sheets http://perl4everything.b Perl IDE Collection logspot.com/2010/12/p << >> source http://www.perlide.org/ erl-cheat-sheets-collect named uops ion.html http://padre.perlide.org/ The Perl Applic Padre < > <= >= lt gt le ge complete, working http://perlmeme.org/star ation Development and Refactoring Enviro == != <=> eq ne cmp examples of good Perl t_here/index.html nment (written in Perl 5) & code Eclipse with the EPIC plugin http://www.epic-id Perl Programming Tutorials http://www.devshed.co e.org/ or with Perlipse http://code.google.co | ^ m/c/b/Perl/ m/p/perlipse/ using dltk && Video from UniverTV http://univertv.ru/searc Acti proprietary Komodo IDE http://www.actives || h/?txt=perl&x=0&y=0 veS tate.com/Products/komodo_ide/ or free .. ... tate Komodo Edit http://www.activestate.com/ FAQ по perl и программи http://www.cyberguru.r Products/komodo_ide/komodo_edit.mhtml ?: рованию для web u/web/web-programmin = += -= *= etc. g/perl-web-programmin Kephra http://kephra.sourceforge.net Programmers g-faq-page2.html Editor along perl-like Paradigms, written in , => Perl FAQ PERL Agava http://hosting.agava.ru/ list ops Gvim www.vim.org with Perl support http://www.v faq/tech/docs/perl.shtml not im.org/scripts/script.php?script_id=556 and Modern::Perl Emacs www.gnu.org/software/emacs/ with CPerl Mode http://www.emacswiki.org/cgi-bin/wik or xor Modern::Perl i/CPerlMode enable all of the features of Modern Perl with one Link to perl cheat import Perl http://www.perlmonks.org/?node=Perl%20D Develo evelopment%20Tools perlcheat Develo evelopment%20Tools perlcheat Toolkit pment http://www.cheatography.com/mishin/cheat-sheets/ use Toolkit; and put all your favorite modules in a Tools perlcheat/ file: > cat $PERL5LIB/Toolkit/Macros/ALWAYS/M odules use strict; use warnings; use Carp; use perl-reference-card Smart::Comments; http://www.cheatography.com/mishin/cheat-sheets/ perl-reference-card/ use common::sense; supposed to be the same, with much lower memory 20-killer-perl-programming-tips usage, as: # # use strict qw(vars subs); # use http://www.cheatography.com/mishin/cheat-sheets/ feature qw(say state switch); # no warnings; # use 20-killer-perl-programming-tips-for-beginners/ 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 parenthesis taint closure semicolon); # no warnings qw(exec newline); latest There is latest, which is no longer the latest. Demonstrates 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 automatically adds strict and warnings to the calling package. Acme::Very::Modern::Perl Using this module, you'll get Modern::Perl, Toolkit, latest, uni::perl, perl5i, and common::sense with just one simple line. Source http://stackoverflow.com/questions/1625839/shoul d-i-use-commonsense-or-just-stick-with-use-strict- and-use-warnings Cheatographer Cheat Sheet Sponsor Nikolay Mishin (mishin) This cheat sheet was published on 1st June, 2012 and FeedbackFair, increase your conversion rate today! cheatography.com/mishin/ was last updated on 2nd July, 2012. Try it free! mishin.narod.ru http://www.FeedbackFair.com.