providing you match works you need () around the pattern
 
i.e.
 
@matches = ( $string =~ m/ expression /xgsi );
otherwise it just returns the scalar result it believe i.e. the number of
matches

   _____  

From: kapil v [mailto:[EMAIL PROTECTED] 
Sent: 12 September 2007 07:44
To: Andrew Curry; beginners@perl.org
Subject: Re: Help with data returned by regex match


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] <mailto:[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. 

Thanks,
Kapil.V


On 9/11/07, Andrew Curry <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote: 

What exactly are you trying to do and what values are you using for your
test?
-----Original Message-----
From: kapil.V [mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> ]
Sent: 11 September 2007 07:06
To: beginners@perl.org <mailto:beginners@perl.org> 
Subject: Help with data returned by regex match

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.) 

Thanks,
Kapil.V

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>  For additional
commands, e-mail: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
http://learn.perl.org/ <http://learn.perl.org/> 



This e-mail is from the PA Group.  For more information, see
www.thepagroup.com  <http://www.thepagroup.com> .

This e-mail may contain confidential information.  Only the addressee is
permitted to read, copy, distribute or otherwise use this email or any
attachments.  If you have received it in error, please contact the sender 
immediately.  Any opinion expressed in this e-mail is personal to the sender
and may not reflect the opinion of the PA Group.

Any e-mail reply to this address may be subject to interception or
monitoring for operational reasons or for lawful business practices. 









This e-mail is from the PA Group.  For more information, see
www.thepagroup.com.

This e-mail may contain confidential information.  Only the addressee is
permitted to read, copy, distribute or otherwise use this email or any
attachments.  If you have received it in error, please contact the sender
immediately.  Any opinion expressed in this e-mail is personal to the sender
and may not reflect the opinion of the PA Group.

Any e-mail reply to this address may be subject to interception or
monitoring for operational reasons or for lawful business practices.




Reply via email to