in reply to How scoping works in If statements?

if you want to assign conditionally only using one line try the ternary operator:
my $x = (1) ? 5 : undef;

Replies are listed 'Best First'.
Re^2: How scoping works in If statements?
by kwaping (Priest) on May 30, 2008 at 18:17 UTC
    That still doesn't address the underlying scoping issue, though.
    use strict; use warnings; my $x = (0) ? 5 : undef; my $x = 42; __END__ "my" variable $x masks earlier declaration in same scope

    ---
    It's all fine and dandy until someone has to look at the code.