|< 1 2 3 >| | 28 Einträge, 3 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
foreach $element (@list)
{
if ($element =~ /host1\.com|host2\.de|host3\.org/)
{
mach was;
}
if ($element =~ /host4\.com|host5\.de|host6\.org/)
{
mach was;
}
if ($element =~ /host7\.com|host8\.de|host9\.org/)
{
mach was;
}
if ($element =~ /host10\.com|host11\.de|host12\.org/)
{
mach was;
}
}
1
2
3
4
5
6
if ($element eq "host1.com" or $element eq "host2.de" or $element eq "host3.org") {
...
}
elsif ($element eq 'host5.cyx' ....) {
}
1
2
3
if (rindex($element, "host1.com") > -1 or
rindex($element, "host2.de") > -1 or
rindex($element, "host3.org") > -1) {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
my %switch = (
"host1.com" => \&DoAction1,
"host2.de" => \&DoAction1,
"host3.xyz" => \&DoAction2,
"host4.das" => \&DoAction3);
if (exists $switch{$element} and ref($switch{$element} eq 'CODE') {
$switch->$element->($param1, $param2, $param3, ...)
}
else {
die "Error: no action for '$element' specified\n";
}
sub DoAction1 {
my ($p1, $p2, $p3) = @_;
print "Action1\n";
}
sub DoAction2 {
my ($p1, $p2, $p3) = @_;
print "Action2\n";
}
sub DoAction3 {
my ($p1, $p2, $p3) = @_;
print "Action3\n";
}
$| = 1
|< 1 2 3 >| | 28 Einträge, 3 Seiten |