This doesn't work from mod_perl, because theeval { ( my %session, $ok ); $ok = tie( %session, 'Apache::Session::MySQL', undef, ... ); if ( $ok ) { ... do something with %session ... } untie %session; }
untie attempted while 1 inner references still exist at foo.pl line 250.Since I don't use any explicit references to %session, this caught me by surprise. I have since resolved it; can you see the bug?
The object returned by the constructor is in turn returned by the tie function, which can be useful if you want to access other methods in CLASSNAME.In other words, I can't untie %session because $ok is still holding a reference to it. One fix is to assign $ok to a constant if and only if tie returns a non-false value, e.g.:
This eliminates the duplicate reference to %session, so my session properly goes away. Thank you each for the alternate solutions suggested by bart and the other monks in CB:eval { ( my %session, $ok ); tie( %session, 'Apache::Session::MySQL', undef, ... ) and $ok = 1; if ( $ok ) { ... do something with %session ... } untie %session; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: unexpected "inner references" error from untie()
by ysth (Canon) on Feb 17, 2009 at 03:50 UTC | |
|
Re: unexpected "inner references" error from untie()
by Anonymous Monk on Feb 17, 2009 at 06:36 UTC |