Thread regexp funktioniert erst beim zweiten Lauf (13 answers)
Opened by dukeofnukem at 2007-06-20 13:23

dukeofnukem
 2007-06-20 16:50
#77687 #77687
User since
2007-01-15
47 Artikel
BenutzerIn
[default_avatar]
Tatsache, die rexexp scheint bei jedem zweiten Aufruf undef zu sein oder false oder sonstwas. Erinnert mich an meinen "glob"-Fehler, aber das sollte doch hier anders sein oder?

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
#!/usr/bin/env perl

use strict;
use warnings;

my @files = @ARGV || glob "*.xml"
or die "No files specified!";

my %xmlstring = (
Hzbprtype => qr/<kBPrType[^>]*>\s*52\s*<\/kBPrType>/,
);

for my $file ( @files ) {
my @cont = do { local(*ARGV, $_, $/); @ARGV = $file; $/ = "</BaseProduct>"; <>; }
if ( -r $file );

for ( @cont ) {

if ( /$xmlstring{'Hzbprtype'}/gs ) {
print "\n$file\ncall #1";
}

if ( /$xmlstring{'Hzbprtype'}/gs ) {
print "\n$file\ncall #2";
}

if ( /$xmlstring{'Hzbprtype'}/gs ) {
print "\n$file\ncall #3";
}

if ( /$xmlstring{'Hzbprtype'}/gs ) {
print "\n$file\ncall #4";
}

if ( /$xmlstring{'Hzbprtype'}/gs ) {
print "\n$file\ncall #5";
}
}
}


Es werden call #1, #3 und #5 ausgeführt....
drum&bass is a state of mind

View full thread regexp funktioniert erst beim zweiten Lauf