Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable question

Status
Not open for further replies.

smokinace

Programmer
Jun 12, 2008
18
0
0
US
what is the hierarchy of variable creation?

if i create a variable inside an if statement using "my" is that variable only good in the if statement?
example

if (condition) {
my ($var1, $var2);
}
 
The answer is yes. Hierarchy is not the proper term though, variables declared with "my" can only be "seen" by the rest of the script within the scope they are defined in. In your case the scope is the block, the stuff between {}.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Scope is the term.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top