<?xml version="1.0" encoding="windows-1252"?>
<node id="201515" title="Re: Re: Re: Re: Regex Capturing: Is this a bug or a feature?" created="2002-09-28 22:45:24" updated="2005-06-18 05:13:23">
<type id="11">
note</type>
<author id="99151">
krusty</author>
<data>
<field name="doctext">
&lt;em&gt;I'd like to change "the outher block" to "an outer (imaginary) block". The outer block I used above isn't written by the coder.&lt;/em&gt;&lt;br&gt;&lt;br&gt;
Seems a funky way to state it, but what I think you're getting at is that if a local variable isn't declared within any existing block, then it will treat the current file as a block.&lt;br&gt;&lt;br&gt;While it is true that the compilation unit itself (as in file or eval statement) can be the scope of a my'd (lexical) or local (dynamic) variable, that's not what's going on here.&lt;br&gt;&lt;br&gt;

&lt;em&gt;What's declared &lt;b&gt;in&lt;/b&gt; that block? Something is declared &lt;b&gt;for&lt;/b&gt; the block rather than in it. &lt;/em&gt;&lt;br&gt;&lt;br&gt;

The first opening curly brace to the closing curly brace of a "for" loop &lt;b&gt;is&lt;/b&gt; a block.  Same thing with "foreach"... (for/foreach are synonyms)&lt;code&gt;
foreach $element @array {#code}&lt;/code&gt;
Perfectly valid block...&lt;br&gt;&lt;BR&gt;

Finally, what's wrong with this:&lt;em&gt;
&lt;code&gt;local ($1, $2) = ($1, $2); # OK, so you can't actually write this.
&lt;/code&gt;&lt;/em&gt;
Try it... It works.&lt;BR&gt;
What you can't do is this:&lt;CODE&gt;
$1 = 50;
&lt;/code&gt;
With warnings turned on you'll get something along the lines of a "modification of read-only value at line x".

&lt;b&gt;Update:  Forget the warnings thing...  &lt;code&gt;$1 = 50;&lt;/code&gt; is a flat out compilation error&lt;/b&gt;



</field>
<field name="root_node">
201446</field>
<field name="parent_node">
201505</field>
</data>
</node>
