C:\_32\pscrpt>type TieFoo.pm
package TieFoo;
sub TIESCALAR {
my $obj = "foo1";
return bless(\$obj, "TieFoo");
}
sub FETCH {
${ $_[0] }++;
}
1;
C:\_32\pscrpt>type demo.pl
use Devel::Peek;
use lib '.';
use TieFoo;
tie $a, 'TieFoo';
print "Initial State: \n";
Dump $a;
print "\nFirst Value: $a\n\n";
print "State after a FETCH: \n";
Dump $a;
####
State after a FETCH:
SV = PVMG(0x1cd4f9c) at 0x1cdf054
REFCNT = 1
FLAGS = (GMG,SMG,RMG,pPOK)
...
##
##
State after a FETCH:
SV = PVMG(0x7deea8) at 0x7cbc58
REFCNT = 1
FLAGS = (GMG,SMG,RMG,POK,IsCOW,pPOK)
....