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

dukeofnukem
 2007-06-20 17:12
#77689 #77689
User since
2007-01-15
47 Artikel
BenutzerIn
[default_avatar]
So funktionierts:

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
#!/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>/s,
);


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

for ( @cont ) {

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

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

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

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

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


Wenn man allerdings versucht die Regexp mit /g direkt in den hash zu compilen knallts ("Bareword found where operator expected [...]"). Wieso ist mir jetzt ehrlich gesagt nicht wirklich klar. Fände es schon interessant, aber für die interessanten Sachen will eh nie einer bezahlen ~:-/

Da ich /g nicht zwingend brauche da es eh nur um einen einzigen boolean match geht isses so auch noch sauberer.

*soifz* another mystery unsolved
drum&bass is a state of mind

View full thread regexp funktioniert erst beim zweiten Lauf