<?xml version="1.0" encoding="windows-1252"?>
<node id="1016701" title="Re: How to store matched $1 values one by one to array?" created="2013-02-02 07:14:55" updated="2013-02-02 07:14:55">
<type id="11">
note</type>
<author id="634253">
AnomalousMonk</author>
<data>
<field name="doctext">
&lt;p&gt;
Here's something that may be close to what you're seeking:
&lt;/P&gt;

&lt;c&gt;
&gt;perl -wMstrict -le
"my $line =
   'xxx:agent_id=&gt;foo,yyy:agent_id=&gt;b\"a\"r,zzz:agent_id=&gt;\"baz\",qqq';
 print qq{'$line'};
 ;;
 my @agents;
 while ($line =~ m{ :agent_id=&gt; (.+?) , }xmsg) {
   my $agent_id = $1;
   printf qq{extracted agent id: '$agent_id'  };
   $agent_id =~ s/\"//g;
   print qq{fixed agent id: '$agent_id'};
   push @agents, $agent_id;
   }
 printf qq{'$_' } for @agents;
"
'xxx:agent_id=&gt;foo,yyy:agent_id=&gt;b"a"r,zzz:agent_id=&gt;"baz",qqq'
extracted agent id: 'foo'  fixed agent id: 'foo'
extracted agent id: 'b"a"r'  fixed agent id: 'bar'
extracted agent id: '"baz"'  fixed agent id: 'baz'
'foo' 'bar' 'baz'
&lt;/C&gt;

&lt;p&gt;
In addition to [doc://perlrequick], see also [doc://perlre] (the guts and the glory) and [doc://perlretut] (a good tutorial, highly recommended).
&lt;/P&gt;
</field>
<field name="root_node">
1016668</field>
<field name="parent_node">
1016668</field>
</data>
</node>
