Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: what is the scope of my $x=$x

by Hue-Bond (Priest)
on Jun 25, 2006 at 01:55 UTC ( [id://557413]=note: print w/replies, xml ) Need Help??


in reply to Re: what is the scope of my $x=$x
in thread what is the scope of my $x=$x

The one on the left hand side of the assignment is a lexical variable and it will be in scope from this statement until the end of the innermost enclosing block.

Minor nit: s/from this statement/from the next statement/; Variables declared with my begin to be visible at the next statement, as documented in perlsub and demonstrated here:

my $c=4; if (my $c and !defined $c) { print "in\n"; }

This prints nothing, since defined is accessing the outer $c (that is defined) even when it's after the my declaration in the same statement.

--
David Serrano

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (1)
As of 2024-04-25 01:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found