This is a list of Perl Syntax/resources that generally we don't know or forget. And please, contribute with your own too.
## this will undef the array:
$#array = -1 ; ## but @array = () is the usual.
## To use here-documents with codes, but without
## parse the code, you use '' as a delimiter of the <<EOF:
print <<'CODE';
This $variable wont be parsed,
and this data will br printed as it was.
CODE
## To add some wild data in REGEXP, is common to see
## codes that filter the data before use it in REGEXP,
## but is much more easy to use \Q\E, instead of something
## like =~ s/[\.\\\/]/\\$1/s :
my $find = 'http://www.domain.foo/' ;
if ( $_ =~ /\Q$find\E/s ) { ... }
## The use \G to continue the search:
while( $_ =~ /(.*)(<.*?>)/s ) { ... }
## And to get what was left by while (after the last <.*?>):
my ($final) = ( $data =~ /\G(.*)$/s ) ;
## When we are looking on REGEXP for something that is after other,
## genreally "\n", we forget about the beggin of the string,
## that enables an occurrence that is not after "\n".
## Soo, to do this in only one REGEXP we use (?:^|\n)
## remove comments:
$str =~ s/(?:^|\n)[ \t]*#//gs ;
## Use of substr():
substr($str , 0 , 0) = ">>" ; ## add data in the begin.
substr($str , 0 , 1) = "ABC" ; ## replace the 1st char with a bigger
+ text.
substr($str , -1 , 1) ; ## get the last char.
substr($str , 0 , -1) ; ## get all the str, but leave the last char
+out.
## Formatting padding:
my $var = sprintf("%06d", 123) ;
print "$var\n" ; ## print 000123
## To generate an array:
my @lyb = (a..z , A..Z , 0..9) ;
## The list:
## a b c d e f g h i j k l m n o p q r s t u v w x y z
## A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
## 0 1 2 3 4 5 6 7 8 9
## Creating an array with 10 elements 'A':
my @l = ('A') x 10 ;
## creating an HASH with 2 arrays,
## one for the keys and other for the values:
my %hash ;
@hash{@keys} = @values ;
## Just to show to beginners the right way for
## concatenation:
$str .= "abc" ; ## and not $str = $str . "abc" ;
## Declaration of my:
if ( my $foo = <IO> ) { ## $foo is in this scope }
open(my $fh , ">out") ; ## all in one line
close($fh);