Re: Lifetime of my variables?
- From: Peter Makholm <peter@xxxxxxxxxxx>
- Date: Tue, 07 Feb 2012 14:56:46 +0100
Shmuel (Seymour J.) Metz <spamtrap@xxxxxxxxxxxxxxxxxxxxxxxxxx> writes:
I could find nothing in the Perl documentation on the lifetime of my
variables. The scope of the name is lexical, but what about the value?
Specifically, if a my variable is declared in a block, does it retain
its value from the previous time you entered the block?
Basically you get a new variable each time you reach the my statement.
If you want to have a variable that keeps the vallue between each time
you enter the block, you should look at state variables. See the perlsub
manual page, the section titled "Persistent Private Variables".
//Makholm
.
- Follow-Ups:
- Re: Lifetime of my variables?
- From: Seymour J.
- Re: Lifetime of my variables?
- References:
- Lifetime of my variables?
- From: Seymour J.
- Lifetime of my variables?
- Prev by Date: Lifetime of my variables?
- Next by Date: Re: Lifetime of my variables?
- Previous by thread: Lifetime of my variables?
- Next by thread: Re: Lifetime of my variables?
- Index(es):
Relevant Pages
|