[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] perl question
- Subject: [ale] perl question
- From: charriglists at bellsouth.net (Calvin Harrigan)
- Date: Mon, 16 Jan 2012 15:59:05 -0500
- In-reply-to: <[email protected]>
- References: <[email protected]>
On 1/16/2012 2:45 PM, Geoffrey Myers wrote:
> Okay, so why is it that $foo is empty inside the sub bar() ??
Because it was never initialized.
set $foo to some value before the loop and be amazed by the weakness of
perl. I kid of course. Localizing the variable means (I think) that
it's the loop variable is taken from the stack even if there is a
variable with the name. So the value of the variable (null in this
case) name perl stays untouched. Only the foreach does this as far as I
know.
<snip>
> Oh the loop works as defined, it's just that the value is not passed
> to the sub bar() My expectation was that since the call to bar() was
> inside the loop, that $foo would be accessible within the sub.
I know the loop seems to work, but the value of the variable(s) are
wrong because of the foreach localization issue I mentioned before.