- or download this
my %chart = (
name => 'vote',
...
print $chart{name}, "\n"; # 'vote'
print $chart{colors}, "\n"; # oops: 'red,green,blue,shape,cubic'
- or download this
if ($true) {
$var = $value;
next;
}
- or download this
while (1) {
warn 1, 2, 3, last if 1;
}
- or download this
$ perl -MO=Deparse,-p -e 'while (1) { warn 1, 2, 3, last if 1 }'
while (1) {
warn(1, 2, 3, last);
}
-e syntax OK
- or download this
my %chart = (
name => 'vote',
...
print $chart{name}, "\n"; # 'vote'
print $chart{colors}, "\n"; # 'red,green,blue'
- or download this
while (1) {
warn(1, 2, 3), last if 1;
}
- or download this
while (1) {
if (1) {
...
last;
}
}
- or download this
$ perl -e 'print chr $ARGV[0], $ARGV[1]' 66 67
B67
- or download this
$ perl -MO=Deparse,-p -e 'print chr $ARGV[0], $ARGV[1]' 66 67
print(chr($ARGV[0]), $ARGV[1]);
-e syntax OK
- or download this
$ perl -e 'print time, "TZ"'
1191177816TZ
- or download this
my $line = 'book|perl|programming';
my @fields = split /\|/, $line;
- or download this
my $line = 'book|perl|programming';
my @fields = split /\|/, $line, 2;
- or download this
my $line = 'Practical extraction and report language';
my $part = substr $line, 10;
- or download this
my $line = 'Practical extraction and report language';
my $what = substr $line, 10, 21; # extraction and report
- or download this
sub upstream {
my(@source, @destination) = @_;
...
my @src = qw(here sender OK);
my @dest = qw(there recipient UNKNOWN);
upstream(@src, @dest);
- or download this
sub upstream {
my($source, $destination) = @_;
...
my @src = qw(here sender OK);
my @dest = qw(there recipient UNKNOWN);
upstream(\@src, \@dest);
- or download this
sub get_group {
my $user_id = shift;
...
my(@specail, @normal) = get_group(1002);
print $special[-1]; # 'games'
print $normal[0]; # undefined
- or download this
sub get_group {
my $user_id = shift;
...
my($specail, $normal) = get_group(1002);
print $special->[-1]; # 'games'
print $normal->[-1]; # 'committee'
- or download this
# syntax: <c>keys HASH</c>
my $rgb = { red => 0x00f, green => 0xf00, blue => 0x0f0 }; # from perl
+data
...
my $another_members = [qw(ray tom dave)];
push $another_members, @names; # fatal: Type of arg 1 to push must be
+array
push @$another_members, @names; # correct
- or download this
sub mypush {
my(@target_array, @new_elements) = @_;
...
}