cybär has asked for the wisdom of the Perl Monks concerning the following question:
$pattern1 = "<name>.*</name>"; $pattern2 = "<age>43</age>"; $file = "data.xml"; $sep = "\n"; open(IN,"<$file"); chomp(@content=<IN>); close IN; $list = join ($sep,@content); if ($list =~ m/$pattern1$sep$pattern2/gi){ print "\n::$&::\n"; print "\n::$1::\n"; print "\n::$2::\n"; }I found only one entry but there are more. Perhaps the join function is not the right in my case, but I didn't know how to look up in an array in my special case, because the two tags are in the array two elements. Please help me. thanks in advance cybär
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: I want to find a group of pattern in a xml file
by Fletch (Bishop) on Sep 16, 2008 at 13:30 UTC | |
by cybär (Initiate) on Sep 16, 2008 at 13:39 UTC | |
|
Re: I want to find a group of pattern in a xml file
by grinder (Bishop) on Sep 16, 2008 at 14:32 UTC | |
|
Re: I want to find a group of pattern in a xml file
by toolic (Bishop) on Sep 16, 2008 at 13:51 UTC | |
|
Re: I want to find a group of pattern in a xml file
by apl (Monsignor) on Sep 16, 2008 at 13:39 UTC | |
|
Re: I want to find a group of pattern in a xml file
by dHarry (Abbot) on Sep 16, 2008 at 13:45 UTC | |
|
Re: I want to find a group of pattern in a xml file
by kubrat (Scribe) on Sep 16, 2008 at 14:44 UTC | |
by cybär (Initiate) on Sep 17, 2008 at 08:11 UTC | |
by Jenda (Abbot) on Sep 17, 2008 at 12:50 UTC |