Leser: 1
|< 1 2 3 4 >| | 32 Einträge, 4 Seiten |
1
2
3
4
5
6
$var = 'routine';
eval(&$var('arg1', 'arg2'));
#eval(&{$var}('arg1', 'arg2'));
sub routine { print "$_\n" for @_; }
1
2
3
4
5
#! /usr/bin/perl
routine('eins', 'zwei');
sub routine{
my ($test,$zwei,$drei) = @_;
}
1
2
3
4
5
#! /usr/bin/perl
my ($eins,$zwei) = routine();
sub routine{
return ('eins','zwei','drei');
}
1
2
3
4
5
#! /usr/bin/perl
my ($eins,$zwei,$drei,$vier) = routine();
sub routine{
return ('eins','zwei','drei');
}
1
2
3
4
5
6
7
8
sub showparam
{
print "$_\n" foreach @_;
}
showparam("Hallo", "Du");
showparam("Hallo", "Du", "!", "Wir", "sind", "ganz", "viele", "Parameter", "!");
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
sub returnthree
{
return ("eins", "zwei", "drei");
}
my ($var1, $var2, $var2, @vars);
$var1 = returnthree();
print "$var1\n";
($var1) = returnthree();
print "$var\n";
($var1, $var2) = returnthree();
print "$var1; $var2\n";
($var1, $var2, $var3) = returnthree();
print "$var1; $var2; $var3\n";
@vars = returnthree();
($var1, undef, $var3) = returnthree();
print "$var1; $var3\n";
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use vars qw(%Config); # "global" ist dafuer manchmal besser
my $cgi = CGI->new();
my $action = $cgi->param('action') || 'default';
%Config = (
default => { subroutine => \&Default, ... },
action1 => { subroutine => \&Action1, ... },
action2 => { subroutine => \&Action2, ... },
);
if (exists $Config{$action} and exists $Config{$action}->{subroutine}) {
$Config{$action}->{subroutine}->($cgi, ...);
}
else { # call default, or errorhandling, or whatever
$Config{default}->{subroutine}->($cgi, ...);
} # else
|< 1 2 3 4 >| | 32 Einträge, 4 Seiten |