On Friday, January 18, 2002, at 12:44 AM, Perrin Harkins wrote:
>> In a Mason context, which is where I'm using it, I do this in my
>> top-level autohandler (ignore the main:: subroutines, they're just for
>> pedagogy):
>>
>>
>> <%init>
>> # 'local' so it's available to lower-level components
>> local *session;
>>
>> my $dbh = &::get_dbh;
>> my $session_id = &::get_cookie('_session_id');
>> tie %session, 'Apache::Session::MySQL', $session_id,
>> {Handle => $dbh, LockHandle => $dbh};
>> ...
>> </%init>
>
> Geez, that's awfully confusing to look at (local and typeglobs is not a
> newbie-friendly combo). Isn't there a simpler way? What about putting
> it in pnotes?
I don't think there's a simpler way. Putting it in pnotes means that
all other components will also have to use $r->pnotes('session'), rather
than just using %session.
Perhaps "local(*session)" is better than "local *session"? It at least
looks less like a "pointer to local". ;-)
-Ken