in reply to Tying with a class method
So %data would now be within the scope of both the subs, and nothing else. Unfortunately this would trip up data(), but you could also include that within the block that connect() and disconnect() are in. For more info on closures check out Why Closures? and other related notes.{ my %data; sub connect { my $self = shift; tie %data, "AnyDBM_File", "data", O_RDWR, 0644 or die "Cannot open data for read.\n"; return 1; } sub disconnect { untie %data; } } # %data has fallen out of scope and only exists # within connect() and disconnect()
_________
broquaint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Tying with a class method
by ninja-joe (Monk) on May 02, 2002 at 16:49 UTC | |
by broquaint (Abbot) on May 02, 2002 at 17:09 UTC |