|
|
Perl SemiPrivate Variables in Function - Perl
|
Views : 250
|
|
Tagged in : Perl
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
Perl SemiPrivate Variables in Function
The local operator is used to define variables of any type that are private to the subroutine there are defined in and any subroutine called within the defininf subroutine.
$value = "original";
tellme();
spoof();
tellme();
sub spoof {
local ($value) = "temporary";
tellme();
}
sub tellme {
print "Current value is $value\n";
}
This code cause the sub tellme to be executed 3 times, printing the results as follows...
first time, prints "original"
second time, prints "temporary"
third time, prints "original"
|
|
By Geethalakshmi, On - 2010-09-17 |
|
|
|