Perl

Install Perl module

# perl -MCPAN -e 'install HTML::CalendarMonthSimple'

# cpan
cpan> install HTML::CalendarMonthSimple

Test if a module is already installed

require HTML::CalendarMonthSimple;

Perl foreach

If you iterate in Perl of something

my @mystuff = ("foo", "bar");

there is automatically a variable $_ with the current iteration in it

foreach(@mystuff)
{
 print "$_";
}

Some commands use this variable if you don't name one

foreach (@mystuff)
{
   /foo/ and print "Found foo!";
}

Man kann aber natürlich auch eine Variable angeben

foreach my $x(@mystuff)
{
 print "$x";
}

See also Perl foreach looping and Perl variables.

Perl Debugger

perl -d myPerlScript.pl

s execute the next command (and step also in method calls)

n next command (but skip method calls)

Return repeat last selection

x $FOO prints the value of the variable

r run until the end of the method (or the next breakpoint)

c run until the end (or the next breakpoint)

l (small L) print the next 10 lines of code

- print the previous 10 lines of code

S print all method names

S main print all method names

b METHODENNAME Brakepoint for this method

b NUMMER Brakepoint for this line number (use l (small L) to get the line numbers)

t print the executed lines

q quit debugger

R Restart program

T Show Stacktrace

See also Perl Debugger