Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
<a name="top">Perl 5 Cheat Sheet</a> by Arjen Laarhoven, based on Juerd Waalboer's cheat sheet <a name="conttoc"><a href="#cont">Contexts</a></a> <a name="sigtoc"><a href="#sig">Sigils</a></a> <a name="arrtoc"><a href="#arr">Arrays</a></a> <a name="hashtoc"><a href="#hash">Hashes</a></a> <a name="scaltoc"><a href="#scal">Scalar values</a></a> <a name="reftoc"><a href="#ref">References</a></a> <a name="prectoc"><a href="#prec">Operator precedence</a></a> <a name="numstrtoc"><a href="#numstr">Numbers/Strings</a></a> <a name="remetatoc"><a href="#remeta">Regex metacharacters</a></a> <a name="remodtoc"><a href="#remod">Regex modifiers</a></a> <a name="rechartoc"><a href="#rechar">Regex character classes</a></a> <a name="funcrettoc"><a href="#funcret">Function return lists</a></a> <a name="specvartoc"><a href="#specvars">Special variables</a></a> <a name="dotoc"><a href="#do">Do</a></a> <a name="donttoc"><a href="#dont">Don't</a></a> <a name="linkstoc"><a href="#links">Links</a></a> <a name="cont"><a href="#conttoc">CONTEXTS</a></a> void scalar list <a name="sig"><a href="#sigtoc">SIGILS</a></a> $scalar @array %hash &sub *glob <a name="arr"><a href="#arrtoc">ARRAYS</a></a> @array @array[0, 2] $array[0] <a name="hash"><a href="#hashtoc">HASHES</a></a> %hash $hash{'a'} @hash{'a','b'} <a name="scal"><a href="#scaltoc">SCALAR VALUES</a></a> number string reference glob undef <a name="ref"><a href="#reftoc">REFERENCES</a></a> \ reference $@%&* dereference [] anon arrayref {} anon hashref \() list of refs $$foo[1] => $foo->[1] $$foo{bar} => $foo->{bar} ${$$foo[1]}[2] => $foo->[1]->[2] ${$$foo[1]}[2] => $foo->[1][2] <a name="prec"><a href="#prectoc">Operator Precedence</a></a> -> ++ -- ** ! ~ / u+ u- =~ !~ * / % x + - . << >> named uops < > <= >= lt gt le ge == != <=> eq ne cmp & | ^ && || .. ... ?: = += -= *= etc. list ops not and or xor <a name="numstr"><a href="#numstrtoc">NUMBERS/STRINGS</a></a> NUM STR = = + . == != eq ne < > <= >= lt gt le ge <=> cmp <a name="remeta"><a href="#remetatoc">REGEX METACHARACTERS</a></a> ^ string begin $ string end + one or more * zero or more ? zero or one {3,7} repeat in range () capture (?:) no capture [] character class | alternation \b word boundary \z string end <a name="remod"><a href="#remodtoc">REGEX MODIFIERS</a></a> /i case insens. /m line based ^$ /s . includes \n /x ignore whitespace /g global <a name="rechar"><a href="#rechartoc">REGEX CHARCLASSES</a></a> . == [^\n] \s == [\x20\f\t\r\n] \w == [A-Za-z0-9_] \d == [0-9] \S, \W and \D negate <a name="funcret"><a href="#funcrettoc">FUNCTION RETURN LISTS</a></a> stat localtime 0 dev 0 second 1 ino 1 minute 2 mode 2 hour 3 nlink 3 day 4 uid 4 mon-1 5 gid 5 yr-1900 6 rdev 6 wday 7 size 7 yrday 8 atime 8 is_dst 9 mtime 10 ctime 11 blksz 12 blcks caller 0 package 5 wantarray 1 filename 6 evaltext 2 line 7 is_require 3 subroutine 8 hints 4 hashargs 9 bitmask 0..9 only with EXPR <a name="specvars"><a href="#specvarstoc">SPECIAL VARIABLES</a></a> $_ default variable $0 program name $/ input separator $\ output separator $| autoflush $! sys/libcall error $@ eval error $$ process ID $. line number @ARGV command line args @INC include paths @_ subroutine args %ENV environment <a name="do"><a href="#dotoc">DO</a></a> use strict; use warnings; my $var; open() or die $!; use Modules; <a name="dont"><a href="#donttoc">DON'T</a></a> "$foo" $$variable_name `$userinput` /$userinput/ <a name="links"><a href="#linkstoc">LINKS</a></a>

In reply to Perl cheat sheet On-the-go by Aragorn

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2023-03-20 10:28 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (59 votes). Check out past polls.