This is an Insane Attempt at Listing PERL Commands

Does it make sense? Are these definitions even correct? Probably not, but I'm learning and somehow this helps. What is Perl, and what's the history? Hell if I know, go to An official Perl Site.

Overview    Scalar Data    Arrays

Variable Types:
$ = scalars, hold 1 variable
@ = arrays, hold variable lists with numerical value starting with 0.
$_ = Default Scalar from array
% = hash, holds paired group lists
{item} = Keys from a hash, not to be confused with a loop
<STDIN> = Standard Input
<STDOUT> = Standard Output
< > = Diamond Operator
@ARGV = Special diamond default array

Control Structures
if
elsif
else
unless
while
until
do
for
foreach
chdir
opendir
readdir
|| = or
{ } = loop start and end characters.

Double Quoted String Escapes
\n Newline
\r Return
\t Tab
\f Formfeed
\b Backspace
\a Bell
\e Escape
\007 Any octel ASCII value (here 007 = bell)
\x7f Any hex ASCII value (here 7f = delete)
\cC Any Control character (here CTRL-C)
\\ Backslash
\* Double Quote
\l Lowercase next letter
\L Lowercase all following letters until \E
\u Uppercase next letter
\U Uppercase all following letters until \E
\Q Backslash-quote all nonalphanumerics until \E
\E Terminate \L, \U, or \Q

String Operators
lt Less than
gt Greater than
le Less than or equal to
eq Equal to
ne Not equal

Numeric Operators
+ Add
- Subtract
/ Divide
** Exponents (Power of)
% Remainder of division (not to be confused with hash)
< Less than
> Greater than
<= Less than or equal to
== Equal to
!= Not equal
++ Auto Increment
-- Auto Decrement
=~ Matches
!~ Doesn't Match

Precedence (first to last) of Operators
Associativity (direction) Operator
Left list
Left -> (method call)
Non ++-- (auto in/decrement)
Right ** (exponentation)
Right ! (not) ~ (bit not) \ (reference) + (plus) - (minus)
Left =~ (matches) !~ (dosen't match)
Left * (multiply) / (divide) % (modulus) x (string replicate)
Left + (add) - (subtract) . (string concatenate)
Left <<>>
Non Named unary operators like chomp
Non <(lt), >(gt), <=(le), >=(ge)
Non ==(eq), !=(ne), <=>(cmp)
Left &(bit and)
Left |(bit or), ^(bit-xor)
Left &&(logical and)
Left ||(logical or)
Non ..(noninclusive range), ...(inclusive range)
Right ?:{if-then-else)
Right = += -= *= (assignment and binary assignment)
Left , (comma) => (comma arrow)
Non list operators Rightward
Right not
Left and
Left or xor


OVERVIEW & Miscellania

whereis perl = lication of perl binary
#!/usr/bin/perl = (shebang) tells system to use perl, #! plus path to perl binary.
# = comment line, is not processed by the program itself, but allows source code notes. perl -cw "scriptname" = Check syntax & Warn if unsafe constructs.

qq = double quote the entire sentence.
qw = double quote each word in the list.
chomp ($variable) removes the default carriage return.
print "content-type:text/html\n\n"; = tells what type of data the script is working with (this example = html).



SCALAR DATA

VALUES can be acted upon by OPERATORS generating a RESULT which can be stored in a VARIABLE.
FREQUENTLY USED TERMS:
Scalar = a real number, able to be represented as a point on a scale.
Unary = having or acting on a singel element.
Interpolation = making insertions.
Integer = whole number, in programming, sending 4.52 to and integer function would return 4. Floating-point = when a numbers decimal placement is changeable, often represented by an exponent, like 4.52E2 = 452, or like the dewey decimal system at a library, verses fixed point decimals like $4.52 = 4 dollars and 52 cents.
Variable = container that holds values.

Numbers - Perl computes only with double-precision floating-point values.
literal = the way data is input to the complier.
integer literals = 1,2,3.
octal literals = start with a 0.
hex literals = start with a 0X.
E = power of 10.

Strings - Strings are sequences of characters, letters are treated the same as numbers.
Literal strings = are single or double quoted.
Single quoted strings = sequence of characters. 'hello' = 5 characters.
Double quoted strings = like single quoted but with more control operators.
Scalar Operators - Produce a new value from other values.
Operators for numbers = 2+3, 5-2, 3*12, 14/2, 10.2/.3, 2**3 (2 to the 3rd power), 10%3 (modulus operator = remainder of a division. Example: 10%3 =1. This works only with whole numbers, so 10.5 % 3.2 gets converted to 10%3), ==,!=, <, >, <+, >=.

Precedence and Associations
Pretty much follows the rules of algebra, but if you're like me and suck at math, a table has been included.
Precedence = what comes first when multiple operators are on the same line, and will be listed in the table from highest to lowest.
Associativity = order of math to perform in a group of equal precedence status.
Right Example: 2 ** 3 ** 4 has RIGHT association so it means the same as 2 ** (3 ** 4), do the 3 ** 4 first = 81, so it's now 2 ** 81.
Left Example: 10 / 5 / 2 = (10 / 5) /2, or 2 / 2, or 1.

Conversion Between Numbers and Strings
Perl converts numbers and strings depending on the type of operator used.
Example: if you used a number operator like + with a string, Perl converts the string to it's number value as if it has been entered as a decimal floating-point value, ignorning any spaces or letters, so 123.45fred becomes 123.45.
If there are no numbers in the string, the value is 0.
If a string operator is used with a number, the numbers get included into the string like letters. It will not convert the letters into Hex or Oct values, for those you need to use the hex & oct operators.
Example using string operator cat: "X" . (4*5) = X . 20 = X20.

Scalar Variables
Scalar Variables hold a single variable. They have a name limit of 255 numbers, letters, and underscores.
The most common operation on a scalar variable is an assignment which is a way to give a value to a variable.

Binary Assignment Operators
$a = $a + 5; can be written like $a += 5; since the same variable is used on both sides. This shorthand is called the binary assignment operator. It can be used with most number operators like *=, .=, -=, etc.

Autoincrement and Autodecrement
Increases or decreases the value of a variable, and can be used with floating-point values, and as prefix and suffix operators.
Floating-point example: $a = 5.2; $b = ++$a; $b is now 6.2.
Prefix example $a = 5; $b = ++$a; both $a and $b are now 6.
Suffix example $a = 5; $b = $a++; $b is now 5 and $a is now 6.

Chop & Chomp
chop = removes last character in a string, can be used repeatedly.
chomp = removes only newline character, no effect when used repeatedly.

Interpolation of Scalars
Double quoted strings get checked for variable names. Variables get replaced by their name value ONCE ONLY.
Example: $x = $'fred'; $y = "hey $x"; print "$y"; = "Hey $fred".
To prevent a value substitution, use single quote or \ before the $.
Example: '$fred' or \$fred. The \ turns off the special value of $.
Use {} to separate variable values.
Example: $fred=pay $fred2="It's ${fred}day"; print $fred2 = "It's payday".
This can also be done with cat.
Example: $fred3 = "It's".$fred."day"; print $fred3 = "It's payday."

Case Shifting
Case shifting string escapes can be used on text brought in with variable interpolation.
Case Shifting String Escapes
$bigfred ="\U$fred"; $bigfred = FRED
$capfred = "\u$fred"; $capfred = Fred
$barney = "\L$BARNEY"; $barney = barney
$capbarney = "\u\L$BARNEY"; $capbarney = Barney

<STDIN> as a Scalar Value
Standard Inputs have a newline at the end by default. In the event that you want to chomp that newline off you could type:
$a = <STDIN>;
chomp ($a); and it'll work, or you could use the following abbreviation:
chomp ($a = <STDIN>); which combinds both lines as the parentheses are carried out first.

Output with Print
This function takes the values in its parenthese and outputs them to your screen unless redirected.

Undefined Value
If you use a scalar variable before you assign a value, it will return a "undef" string value and a 0 numeric value.


ARRAYS

List = orders scalar data. Array is a variable that holds a list.
List Literal = the way you represent the value of a list within your program.
List contructor operator = two values separated by two periods.
example: (1 .. 5) = (1,2,3,4,5) or (1.2 .. 5.2) = (1,2,3,4,5)
qw = qwote word function = short cut that represents quoting each element in a list as a string, in place of quotes.
example: @a = qw(fred barney); = @a = ("fred", "barney");
Coupled (oh excuse me, Interpolated) with some other variables like print gives stuff like:
example: print @a;   # which will print @a array without any "white spaces" or newline.
print @a, "\n';    # will print no whitespaces and a newline.
print "@a\n";    # now @a is included in the print statement so it prints with whitespaces. Freaky at first, but makes sense now.
If an array is assigned to a scalar, the number assigned is the length of the array.
Example: @fred = (4,5,6); $a = @fred; print $a,"\n";    # will print out 3.
Also, if you put $a in parens ($a) = @fred, it means the first element of @fred, in this case 4.

Items (or elements) in a list are numbered by their placement, starting with 0.
@fred = (7,8,9);
$a = $fred[0];       #$a is now 7, the first element of @fred.
$fred[0] = 5;       #now @fred changes to (5,8,9) because we changed the value of the first element.
1