Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^2: To initialise or not to initialise?

by iburrell (Chaplain)
on Jun 24, 2004 at 16:01 UTC ( #369412=note: print w/replies, xml ) Need Help??

in reply to Re: To initialise or not to initialise?
in thread To initialise or not to initialise?

Are you really using global variables? You should be using lexical variables, declared with my, everyhere you can. For example, you can declare the loop variable inside the for statement.
foreach my $item (@array) {

I don't like the style of declaring lexical variables at the top of a function. I much prefer declaring the variable where it is first assigned. It must be a carryover from C where that is the only way to declare variables. But I can understand it.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://369412]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2021-10-18 15:01 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (74 votes). Check out past polls.