<?xml version="1.0" encoding="windows-1252"?>
<node id="554954" title="Re: Iterating over code embeded in regex" created="2006-06-13 01:34:03" updated="2006-06-12 21:34:03">
<type id="11">
note</type>
<author id="491819">
ioannis</author>
<data>
<field name="doctext">
The snippet bellow shows that the $l inside the embedded code
of the regex is a closure.
&lt;p&gt;

&lt;code&gt;
use Scalar::Util 'refaddr';

for my $l ('a'..'b') {
        print 'loop variable ', refaddr \$l;
        $l =~ /(?{ print refaddr(\$l) }) /x;
}
&lt;/code&gt;
&lt;p&gt;
Here is the output:
&lt;code&gt;
loop variable 135603848
135606104
loop variable 135606092
135606104
&lt;/code&gt;</field>
<field name="root_node">
554941</field>
<field name="parent_node">
554941</field>
</data>
</node>
