perl "my" problem
Good day,
If I declare some thing in a loop like Code:
use strict; It tells me "Global symbol "$temp" requires explicit package name at..." Any ideas ? |
Since you declared it within a block, it does not exist outside of that block. Declare/initialize it before the if statement.
http://en.wikipedia.org/wiki/Scope_(programming) |
So can I make macro othe top of program, #define style?
Problem is this loop is going to run through many entries. And I want to keep certain variables, even when the loop ends. |
Quote:
Using "my" means that the particular chunk doesn't exist outside that loop. Leaving it off will define it globally, so other loops can use it. |
So you suggest I don't use "strict" ?
Because when I take of my from the loop/block It bring back same error on that line. |
No, I suggest you do this.
Code:
use strict; |
oh
Its so much like C. Thanks alot. |
Quote:
|
All times are GMT -5. The time now is 08:49 PM. |