|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
Stuck with RegEx (Parsing whois output)by marsch (Initiate) |
| on Sep 28, 2004 at 08:40 UTC ( #394500=perlquestion: print w/ replies, xml ) | Need Help?? |
|
marsch has asked for the
wisdom of the Perl Monks concerning the following question:
Hello folks, I have a little problem like that: In a file are different sections. In these sections are key-value pairs. Every pair can occur arbitrary times. To be more sophisticated, every section can have several names. Sections are divided by one or more empty lines. An example:
{section1}
key1: value1_1
key2: value2_1
key2: value2_2
key3: value3_1
...
{section2}{section3}
key1: value1_1
key2: value2_1
key2: value2_2
key2: value2_3
key3: value3_1
...
My problem is to find out all lines of a certain key in a distinct section, e.g. find all values of key2 in section 2. I tried with and without look-aheads and look-behinds, all I get is either the first or the last value, but never all of them (should be 3 elements):
UPDATE: I try to tune Net::XWhois (DENIC parser), which uses an engine like @matches = $self->{ Response } =~ /${$self->{Parser}}{$key}/sg; to get the entries, so my task is to set up a new parser. Is it possible at all to solve this problem? Thanks for any hint Marco
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||