- or download this
my @array = qw /One Two Three/;
my $var = 2;
print $array[$var], "\n";
- or download this
my %hash = ( 1 => One, 2 => Two, 3 => Three);
my $var = 2;
print "$hash{$var}\n";
- or download this
my ($oper, $rest) = shift, join ' ', @_;
my $stop = 'stop';
...
else {
die "Unknown operation: $oper \n";
}
- or download this
my %dispatch_table = (
stop => sub {run_stop($rest); cleanup();},
...
start => /&run_start(@rest),
force_start => sub {run_stop ($rest); cleanup() ; run_start ($res
+t);},
);
- or download this
my ($oper, $rest) = shift, join ' ', @_;
if (defined $dispatch_table{$oper}) {
...
} else {
die "Unknown operation: $oper \n";
}