On Tue, Mar 08, 2005 at 10:30:36PM -0500, Randy W. Sims wrote: > What about the "resource aquisition is initialization" approach?
Oh ick no. Means on every subroutine entry you have to call a magic, mysterious TB method. > package TB; > sub new { bless { level => \my $level }, shift } > sub obtain { TB::_level->new( shift->{level} ) } > 1; > > package TB::_level; > sub new { ${$_[1]}++; bless { level => $_[1] }, $_[0] } > sub DESTROY { ${shift()->{level}}-- } > 1; > > package main; > use Data::Dumper; > > my $tb = TB->new; > print Dumper $tb; > { > my $l = $tb->obtain; > print Dumper $tb; > { > my $inner_l = $tb->obtain; > print Dumper $tb; > } > } > print Dumper $tb; > > __END__