Thread Zeitbegrenzung für reguläre Ausdrücke (40 answers)
Opened by Crian at 2005-04-25 13:24

Crian
 2005-04-26 16:30
#54180 #54180
User since
2003-08-04
5873 Artikel
ModeratorIn
[Homepage]
user image
@taulmarill: Das ist ein (1) regulärer Ausdruck und ein (1) Text, der da so lange läuft. Da kann ich nicht mit Häppchenweise ankommen.

Mit besserer Hardware kann man da auch nix machen, jedenfalls nicht in dem Rahmen. Wenn so ein Regex aus dem Ruder läuft, bringt da besere Hardware leider auch nichts mehr.

Der Ausdruck ist echt harmlos, die Daten auch. Kann ich heute Abend mal mitbringen, posten ist schlecht wegen Firmen-Interna.



@strat: ich hab das local mal weggelassen, aber das wars auch nicht.

Ich hab mich jetzt mal auf den fork-Weg gemacht, aber da komme ich auch nicht weiter. Das Problem bleibt irgendwie das gleiche.

Mein Testprogramm:

Code: (dl )
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl
use strict;
use warnings;

pipe PREAD, CWRITE; # child -> parent

if (fork) {
parent1();
}
else {
child();
}


sub child {
close PREAD; # child - close parent end of pipe

print "child: start of proccess\n";
syswrite CWRITE, "0\n";
for (1..5) {print "child zZZZzzz\n";sleep 1;}
print "child is awaking\n";
syswrite CWRITE, "$_\n" for 1 .. 10;
print "child ending\n";
exit;
} # sub child


sub parent1 {
close CWRITE; # parent - close child end of pipe

chomp(my @erg = <PREAD>);
print "parent got ", join(' - ', @erg), "\n";
print "parent : ", (eof(PREAD)?'ENDE':'keine Ende'), "\n";
} # sub parent1


sub parent2 {
close CWRITE; # parent - close child end of pipes

my @erg;
eval {
$SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
alarm 2;
chomp(@erg = <PREAD>);
alarm 0;
};
if ($@) {
die "other error : $@"
unless $@ eq "alarm\n"; # propagate unexpected errors
warn "parent : child got time out!\n";
}
else {
alarm 0; # Ist das wirklich notwendig?
print "parent got ", join(' - ', @erg), "\n";
print "parent : ", (eof(PREAD)?'ENDE':'keine Ende'), "\n";
}
} # sub parent2


lässt man dies nun mit parent1 laufen, erhält man dieses Ergebnis:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
C:\Daten\perl\fork>f4.pl
child: start of proccess
child zZZZzzz
child zZZZzzz
child zZZZzzz
child zZZZzzz
child zZZZzzz
child is awaking
child ending
parent got 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10
parent : ENDE


Lässt man hingegen parent2 los, erhält man exakt das gleiche Ergebnis, und das finde ich echt frustrierend.
s--Pevna-;s.([a-z]).chr((ord($1)-84)%26+97).gee; s^([A-Z])^chr((ord($1)-52)%26+65)^gee;print;

use strict; use warnings; Link zu meiner Perlseite

View full thread Zeitbegrenzung für reguläre Ausdrücke