new "state" variables... nest properly??
- From: Abble <grg2@xxxxxxxxxxx>
- Date: Thu, 27 Dec 2007 14:14:05 -0800 (PST)
Do the new "state" variable declaration stuff mean that finally you
can nest subs and variables will behave properly? Great news, if
true.
My little test program seems to indicate this is correct:
use strict; use warnings; use English; use feature 'state';
my( $GVar );
sub Outer{ my( $Arg ) = @_; state ( $Var );
sub Inner{
if( $GVar eq $Var ) { print "midvar is okay: $Var\n" }
else { print "midvar should be '$GVar' but is '$Var'\n" }
}
#begin Outer
if( $Var ) { print "*** Var preset!!! to '$Var' \n" }
else { print "Var unset as supposed to be!\n" }
$Var = $Arg;
$GVar = $Var;
Inner( );
}
print $];
Outer( 'foo 1' ); Outer( 'foo 2' ); Outer( 'foo 3' );
.
- Follow-Ups:
- Re: new "state" variables... nest properly??
- From: Ben Morrow
- Re: new "state" variables... nest properly??
- Prev by Date: Re: count the number of occurences of each different word of a text
- Next by Date: Re: Regular Expression for XML Parsing
- Previous by thread: Regular Expression for XML Parsing
- Next by thread: Re: new "state" variables... nest properly??
- Index(es):