On 11 Sep 2007 at 11:36, kapil.V wrote: > Hi, > > #!/usr/bin/perl -w > my $path = shift; > my $machine = shift; > my (undef,$country, $property) = split /\//,$path; > my $xmlData = qx!./pindown. php $machine!; > my @contacts = $xmlData =~ /property name=\"$property\ " > country=\"$country\ ">.+?<contact type=\"admin\ ">.+?<\/contact> /is; > #print "$&\n"; > print @contacts; > > This prints "1" > But printing $& prints a block of XML. > Why does the array contacts not contain the pattern matched?(Also tried > assigning the matched pattern to a scalar.)
1 is the number of times it made a match. I am not sure about capturing patterns into arrays. I would have tried to capture the string like this: (my $match) = ($xmlData =~ /property name=\"$property\ " country=\"$country\ ">.+?<contact type=\"admin\ ">.+?<\/contact> /is); No sure if it's the most efficient way though and I am not sure if that's exactly what your trying to do. HTH, Dp. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/