in reply to please, PLEASE use strict!
in thread Running a subroutine a certain number of times

I was waiting for someone to say that.

No, use strict would not magically solve the problem. By putting use strict on top of the code, and my $i above the first loop, you would still have had the same problem: the loop variable is still shared.

You solve the problem by putting my $i in the subroutine, or in the inner block. But you don't need use strict to do so.

Abigail

Replies are listed 'Best First'.
Re: Please, please don't treat use strict as a magic wand that solves all problems.
by dreadpiratepeter (Priest) on Aug 05, 2002 at 14:45 UTC
    True, but I find that getting people in the habit of using strict also gets them in the habit of scoping all their variables properly, so the mistake becomes far less likely to happen.
    But I agree, use strict is not a substitute for use your_brain.


    -pete
    "Pain heals. Chicks dig scars. Glory lasts forever."
use strict isn't your magic wand, but your spellbook!
by flocto (Pilgrim) on Aug 05, 2002 at 15:04 UTC

    I did not say that 'use strict' magically solves all your problems, but that this mistake would not have been as easy to happen.

    Regards,
    -octo