Framework | Memo |
---|---|
Mojolicious | http://mojolicio.us/ |
Catalyst |
use strict; use warnings;
print "Hello world";
my $num; my @students my %month_num;
my $num = 1; my $num = 1.234; my $num = 100_000_000;
$div = int(3/2); $mod = 3 % 2;
$i++ $i--
my $str1 = 'abc'; my $str2 = "def"; my $str3 = "a\tbc\n"; my $str4 = "$str1 def"; # abc def
my $join1 = 'aaa' . 'bbb'; my $join2 = join(',', 'aaa', 'bbb', 'ccc'); my @record = split(/,/, 'aaa,bbb,ccc'); my $length = length 'abcdef'; my $substr = substr('abcd', 0, 2); # ab my $result = index('abcd', 'cd');
my @array; @array = (1, 2, 3);
$array[0]; $array[1]; $array[0] = 1; $array[1] = 2;
my $array_num = @array;
my $first = shift @array; unshift @array, 5; my $last = pop @array; push @array, 9;
if (condition) { }
if (condition) { } else { }
if (condition1) { } elsif (condition2) { }
my $i = 0; while ($i < 5) { # $i++; }
for (my $i = 0; $i < 5; $i++) { # }
foreach my $field (@fields) { # }
$p == $q $p != $q $p < $q $p > $q $p <= $q $p >= $q
$s eq $t $s ne $t $s lt $t $s gt $t $s le $t $s ge $t
sub sum { my ($num1, $num2) = @_; my $total = $num1 + $num2; return $total; }
open my $fh, '<', $file or die "Cannot open '$file': $!"; while (my $line = <$fh>) { # } close $fh;
my $conf_file = "app.conf"; my $conf = do $conf_file or die qq/Can't load config file "$conf_file": $!$@/;
{ name => 'Foo', number => 9 }