How can I access a dynamic variable while a similarly named lexical is in scope?
You can do this via symbolic references, provided you haven't set use strict "refs". So instead of $var, use ${'var'}.
sub lexical {
my $var = 'private';# new private variable, $var
visible(); # (invisible outside of sub scope)
}
$var = 'global';
visible(); # prints global
dynamic(); # prints local
lexical(); # prints global
Notice how at no point does the value ``private'' get printed. That's because
$var only has that value within the block of the lexical()
function, and it is hidden from called subroutine.
In summary, local() doesn't make what you think of as private,
local variables. It gives a global variable a temporary value. my()
is what you're looking for if you want private variables.
Hey, I have a question thats been bugging me, if you can help me, please mail me the solution @ neester_@hotmail.com...
My question is, Is it possible to make a Perl/CGI script that Saves the content of a URL to a file... ie. If the user navigates to:
http://mysite.com/cgi-bin/logger.pl?I+WANT+TO+BE+ABLE+TO+SAVE+THIS+TEXT is that possible? if it is, i am guessing it wont be too hard, i have been researching for the last hour, but to no avail...
I came upon a lot of your submissions, and you look like a pro, so yeah. can you help me? please! thank you! (If this comment was disrespectful, please report it.)
Have ever seen wordcrucnher I was wondering if you can emmulate it for me as a contract on rentacoder? Thanks ldapguru@yahoo.com (If this comment was disrespectful, please report it.)
Add Your Feedback
Your feedback will be posted below and an email sent to
the author. Please remember that the author was kind enough to
share this with you, so any criticisms must be stated politely, or they
will be deleted. (For feedback not related to this particular article, please
click here instead.)