in reply to Re: scope of my $x in if statements
in thread scope of my $x in if statements

The first expands the scope of $x.

Replies are listed 'Best First'.
Re^3: scope of my $x in if statements
by ikegami (Patriarch) on May 08, 2009 at 01:54 UTC

    So?

      Just a nit, unless one is concerned that this $x should be out of scope after the end of the if block. The outer scope could have its own $x, for example.

        Limiting the scope to the if doesn't limit the lifetime of the value for destruction purposes (see if(my) scope), and if the outer scope already has an $x, you'll get a warning (easily fixed by using curlies or the other alternative I posted).