Created
November 21, 2014 17:47
-
-
Save gregpinero/19f0a081520cbef83923 to your computer and use it in GitHub Desktop.
Perl Syntax Basics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Perl syntax basics: | |
Perl === | |
Start interactive interpreter: | |
perl -de 1 | |
==== Syntax Basics ==== | |
<pre><nowiki> | |
data types: $scalars, @lists, and %hashes | |
""my"" makes a variable be in the scope of its block and lower. Use ""our"" for globals. | |
Put ""use strict"" at beginning of file to be required to declare variables. | |
Put ""use warnings"" at beginning of file to get helpful messages? | |
Conditional operators: ||, &&, !, == (but you can also use and, or, not, xor | |
Strings: "" for interpolation, ' for raw | |
Concatenation: . | |
ternary hook: a?b:c | |
Importing: | |
use Module; --brings in entire namespace | |
use Module (symbol1, symbol2, symbol3); | |
require Module; | |
Module::func(); | |
Magical entities: | |
$_ means ?? | |
@_ This is where function arguments are stored. | |
@ARGV command line arguments | |
$ARGV Name of current file? | |
$$ Process ID | |
$< user id | |
There are many more, just look up anything suspicious I guess. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment