in reply to Re: Re: to strict or not to strict
in thread to strict or not to strict

I do declare variables in the smallest scope possible -- but I do also put them at the beginning of the block. I find it's easier to organize, and I tend to think about my code more before I write it.

Replies are listed 'Best First'.
Re: Re: Re: Re: to strict or not to strict
by Juerd (Abbot) on Oct 17, 2003 at 07:26 UTC

    I do declare variables in the smallest scope possible -- but I do also put them at the beginning of the block.

    Either you have a lot of very small blocks, or you're contradicting yourself.

    { my $foo; ... # n1 lines $foo = bar(); ... # n2 lines print $foo; }
    Scope of $foo: n1 + n2 + 3 lines
    { ... # n1 lines my $foo = bar(); ... # n2 lines print $foo; }
    Scope of $foo: n2 + 2 lines.

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      Erm. I suppose I'm contradicting myself, then.

      I mean to say that I'm not using globals if I can avoid it -- but I do declare variables at the beginning of the subroutines. So the first style you presented is a lot closer to how I write code.