On 9/12/07, kapil v <[EMAIL PROTECTED]> wrote: > The input is an xml file. It contains nodes like > <some tags> > <property name = some_name country = some_country> > <optional ttags> > <contact type=admin> > <optional tags> > <email> > [EMAIL PROTECTED] > </email> > </contact> > <some tags> > I want to find the contact e-mail for a given property. > I did a workaround by using $& to get the pattern matched, and processed it > to get the e-mail, but it is confusing why the matched pattern is not > captured by the assigned variable. snip
It is simple, you have no captures (things in parens) and when you have no captures a regex it returns (1) in list context if it matches. Just add a capture to your regex: my @contacts = $xmlData =~ /(property name="$property" country="$country">.+?<contact type="admin">.+?<\/contact> )/is; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/