in reply to How scoping works in If statements?

Hello Prasad, both the statments are wrong. when you write
#case 2: my $x = 5 if (1); print $x; #prints 5
for compiler $x is visible outside even though it does operations like case 1. so
my $x=4 if(1); #x is as good as global for this file. if(1) { my $x=5; # x is visible inside the block for compiler so it makes it +inside. }
so use braces if u want to make it part of if only.