Do not use smartmatch - operator ~~ and given/when statements. They are marked experimental in recent Perl versions.
Do not use source filters. See a discussion on why it is bad.
Starting every Perl program with these lines:
This will ensure a better, cleaner code.
my
keyword. 'use strict' also tosses up errors if your code contains any barewords that can't be interpreted in their current context. Those two lines are a must, even for very small scripts.my %COMMANDS = (
help => {function => \&cmd_help, usage => 'help <command> - print usage information'},
...
)
'-bt=2
')'-pt=2
')sub nicer
{
my $nice = shift;
$nice += 10;
return $nice;
}
if ($strict == 0 or ($str ne "" and $length <= 10))
shift
. Always separate unpacking with an empty line. For example, instead of:Use:
sub reply
{
my $recipient = shift; # message recipient
my $replymsg = shift; # raw IRC message (can contain colour codes)
$irc→yield(privmsg => $recipient, $replymsg);
}
Or:
if
statements or the Switch::Plain module. if
statements can be less readable, the module is an extra requirement that requires a recent Perl and is XS based, thus might need a C compiler to install.