<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16544" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Ok, thanks, I believe you. I just didn't expect
that. I was thinking in C++ terms, where that variable would be declared
on the stack frame and would persist until the loop exits.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>----- Original Message ----- </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=fulko.hew@gmail.com href="mailto:fulko.hew@gmail.com">Fulko Hew</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=tpm@to.pm.org
href="mailto:tpm@to.pm.org">tpm@to.pm.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Wednesday, October 31, 2007 8:13
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [tpm] Weird arrary reference
bahaviour</DIV>
<DIV><FONT face=Arial size=2></FONT><BR></DIV><BR>
<DIV><SPAN class=gmail_quote>On 10/31/07, <B class=gmail_sendername>Indy
Singh</B> <<A href="mailto:indy@indigostar.com">indy@indigostar.com</A>>
wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Hi
Guys,<BR>Can anyone explain, why taking a reference to an array gives a
different<BR>value on each iteration of this loop. This is the
line of code:<BR> my $r = \@f;<BR><BR>If I move the "my @a"
declaration outside the loop I get the same value <BR>each time.<BR><BR>It
seems that on each iteration of the loop a new @f array is created.<BR>Does
that make sense?</BLOCKQUOTE>
<DIV><FONT face=Arial size=2></FONT><BR>... snip ... <BR><BR></DIV>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">foreach
$x (@foo) {<BR> my @f;</BLOCKQUOTE>
<DIV><FONT face=Arial size=2></FONT><BR>... snip ...<BR><BR>Yes, this make
sense because my @f is a variable declared<BR>every time the body of the
foreach loop is executed.<BR>(for the same reason that the split is executed
every <BR>time through the loop too.)<BR></DIV><BR></DIV>
<P><FONT face=Arial size=2></FONT></P></BLOCKQUOTE></BODY></HTML>