|< 1 2 3 >| | 21 Einträge, 3 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/perl
use strict;
use warnings;
use diagnostics;
sub foo {
my $var = 'x';
sub test {
$var=1;
print $var."\n";
}
test;
$var = 'y';
}
foo;
test;
1
2
3
4
5
6
7
8
9
10
11
#!/usr/bin/perl
use strict;
use warnings 'all';
&test;
sub test
{
my $var=1;
print $var."\n";
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl
use strict;
use warnings 'all';
&test;
sub test
{
my $var = 1;
sub test2
{
print $var."\n";
}
&test2;
}
1
2
3
4
5
6
7
8
# entweder
$test2 = sub { print $var."\n" }
# oder
sub test2
{
my $var = shift;
print $var."\n";
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl
use strict;
#use warnings 'all';
&test;
sub test
{
my $var = 1;
sub test2
{
print $var."\n";
}
&test2;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
sub create_iter {
my $start = shift || 1;
my $func = shift || sub { $_[0] += 1 };
return sub { my $t = $start; $func->($start); return $t }
}
my $iter = create_iter(17, sub { $_[0] += 2 });
while (my $i = $iter->()) {
last if $i > 25;
print $i . "\n";
}
my $iter2 = create_iter(1, sub { $_[0] *= 2 });
while (my $i = $iter2->()) {
last if $i > 256;
print $i . "\n";
}
|< 1 2 3 >| | 21 Einträge, 3 Seiten |