<?xml version="1.0" encoding="windows-1252"?>
<node id="662205" title="Re^4: Lexical scoping like a fox" created="2008-01-13 14:07:24" updated="2008-01-13 09:07:24">
<type id="11">
note</type>
<author id="510280">
shmem</author>
<data>
<field name="doctext">
&lt;blockquote&gt;&lt;i&gt;
1)using input record separator as newline indicator is very interesting. Never seen it before but works well. Any reason?
I am assuming it's just a style issue?
&lt;/i&gt;&lt;/blockquote&gt;
&lt;p&gt;I guess it's more along "a \n is a \n is a \n" - $/ is a global, and that could be changed far away without you knowing it; so it's more safety than style.
&lt;blockquote&gt;&lt;i&gt;
2)Below code from tutorial does not work when I insert my next to variable.. can someone explain this?
&lt;/i&gt;&lt;/blockquote&gt;
&lt;p&gt;You are allocating a lexical $x, not a package global (which would be either &lt;c&gt;use vars '$x'&lt;/c&gt; or &lt;c&gt;our $x&lt;/c&gt;), and [doc://local] aliases only package globals. You can't (shouldn't) allocate globs and lexicals of the same name in the same scope:
&lt;c&gt;
our $x;
my $x; # gives a warning
&lt;/c&gt;
&lt;c&gt;
our $x;
{
    my $x; # ok
}
&lt;/c&gt;
&lt;blockquote&gt;&lt;i&gt;
3)can someone explain further on "lexical variables are declared at compile-time, not initialised?
Is this because BEGIN runs during compile-time? I sneaked in a new my $foo = something inside of BEGIN
block and execution of the code came out w/ foo is something during BEGIN phase
&lt;/i&gt;&lt;/blockquote&gt;
&lt;p&gt;"lexical variables are declared at compile-time, not initialised" means "the container is created, but
nothing is put into it". The initialization (= puting something into the bucket) happens at run time.
BEGIN blocks are compiled &lt;i&gt;and immediately run&lt;/i&gt;, that's why "code came out w/ foo is something during BEGIN phase".
&lt;p&gt;See also [id://94027].
&lt;div class="pmsig"&gt;&lt;div class="pmsig-510280"&gt;
&lt;p&gt;--shmem
&lt;small&gt;&lt;small&gt;&lt;pre&gt;
_($_=" "x(1&lt;&lt;5)."?\n".q&amp;middot;/)Oo.  G&amp;deg;\        /
                              /\_&amp;macr;/(q    /
----------------------------  \__(m.====&amp;middot;.(_("always off the crowd"))."&amp;middot;
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e &amp;&amp; print}&lt;/pre&gt;&lt;/small&gt;&lt;/small&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
213855</field>
<field name="parent_node">
662192</field>
</data>
</node>
