Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: How scoping works in If statements?

by Anonymous Monk
on May 30, 2008 at 09:53 UTC ( [id://689174]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://689174]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-03-28 20:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found