Leser: 1
10 Einträge, 1 Seite |
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
28
29
30
31
32
33
34
35
36
MYLOOP: while ( 1 ) {
open my $fh1, '<', "$file1" or do {
print STDERR "unable to open $file1: $!\n";
print STDERR "sleep for 3 seconds\n";
sleep 3;
print STDERR "wakeup\n";
next MYLOOP;
};
# irgendeine Verarbeitung
close $fh1;
open my $fh2, '<', "$file2" or do {
print STDERR "unable to open $file2: $!\n";
print STDERR "sleep for 3 seconds\n";
sleep 3;
print STDERR "wakeup\n";
next MYLOOP;
};
# irgendeine Verarbeitung
close $fh2;
open my $fh3, '<', "$file3" or do {
print STDERR "unable to open $file3: $!\n";
print STDERR "sleep for 3 seconds\n";
sleep 3;
print STDERR "wakeup\n";
next MYLOOP;
};
# irgendeine Verarbeitung
close $fh3;
}
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
28
MYLOOP: while ( 1 ) {
open my $fh1, '<', "$file1" or foobar($file1);
# irgendeine Verarbeitung
close $fh1;
open my $fh2, '<', "$file2" or foobar($file2);
# irgendeine Verarbeitung
close $fh2;
open my $fh3, '<', "$file3" or foobar($file3);
# irgendeine Verarbeitung
close $fh3;
}
sub foobar {
my $file = shift;
print STDERR "unable to open $file: $!\n";
print STDERR "sleep for 3 seconds\n";
sleep 3;
print STDERR "wakeup\n";
{
no warnings "exiting";
next MYLOOP;
}
}
unless(open (my $fh1, '<', "$file1")) { ... Fehlerbehandlung ...}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
MYLOOP: while ( 1 ) {
open my $fh1, '<', "$file1" or foobar($file1) and next;
# irgendeine Verarbeitung
close $fh1;
open my $fh2, '<', "$file2" or foobar($file2) and next;
# irgendeine Verarbeitung
close $fh2;
open my $fh3, '<', "$file3" or foobar($file3) and next;
# irgendeine Verarbeitung
close $fh3;
}
sub foobar {
my $file = shift;
print STDERR "unable to open $file: $!\n";
print STDERR "sleep for 3 seconds\n";
sleep 3;
print STDERR "wakeup\n";
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/perl
use strict;
use warnings;
MYLOOP: for(0..10){
$_ % 2 or test();
print $_,"\n";
}
sub test{
print "not % 2\n";
next MYLOOP;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/perl
use strict;
use warnings;
MYLOOP: for(0..10){
unless($_ % 2){test()};
print $_,"\n";
}
sub test{
print "not % 2\n";
next MYLOOP;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
~/entwicklung 10> perl modulo.pl
not % 2
Exiting subroutine via next at modulo.pl line 13.
1
not % 2
Exiting subroutine via next at modulo.pl line 13.
3
not % 2
Exiting subroutine via next at modulo.pl line 13.
5
not % 2
Exiting subroutine via next at modulo.pl line 13.
7
not % 2
Exiting subroutine via next at modulo.pl line 13.
9
not % 2
Exiting subroutine via next at modulo.pl line 13.
unless(open (my $fh1, '<', "$file1")) { ... Fehlerbehandlung ...}
1
2
3
4
5
MYLOOP: while ( 1 ) {
open my $fh1, '<', "$file1" or foobar($file1) and next;
# irgendeine Verarbeitung
close $fh1;}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$socket->connect() or do {
my $errstr = $socket->errstr();
$logger->write("unable to connect to $server:$service ($errstr)");
$socket->disconnect();
sleep $recon;
next ENDLESS;
};
$logger->write("connect to $server:$service successful");
$socket->send($auth) or do {
my $errstr = $socket->errstr();
$logger->write("unable to send client data to $server:$service ($errstr)");
$socket->disconnect();
sleep $recon;
next ENDLESS;
};
1
2
3
4
5
6
7
8
9
10
11
my %messages = (
1 => 'cannot connect to server',
2 => 'unable to send data',);
$socket->connect() or logging($socket,$logger,$messages{1})
and next;
sub logging{
my ($sock,$log,$msg) = @_;
$log->write($msg . $sock->errstr());
$sock->disconnect;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
MYLOOP: for(0..10){
$_ % 2 or test(CGI->new, 'header') and next;
print $_,"\n";
}
sub test{
my ($obj,$method) = @_;
no strict 'refs';
print $obj->$method();
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
~/entwicklung 25> perl modulo.pl
Content-Type: text/html; charset=ISO-8859-1
1
Content-Type: text/html; charset=ISO-8859-1
3
Content-Type: text/html; charset=ISO-8859-1
5
Content-Type: text/html; charset=ISO-8859-1
7
Content-Type: text/html; charset=ISO-8859-1
9
Content-Type: text/html; charset=ISO-8859-1
1
2
3
4
5
6
7
8
9
10
11
my %messages = (
1 => 'cannot connect to server',
2 => 'unable to send data',);
$socket->connect() or logging($socket,$logger,$messages{1})
and next;
sub logging{
my ($sock,$log,$msg) = @_;
$log->write($msg . $sock->errstr());
$sock->disconnect;
}
10 Einträge, 1 Seite |