Eyck has asked for the wisdom of the Perl Monks concerning the following question:
I've been bitten by a side effect, here's example code from documentation of Net::SSLeay::Handle:
my $socket \*S1; if ($scheme eq "https") { tie(*S2, "Net::SSLeay::Handle", $socket); $socket = \*S2; }
This works OK, unfortunatelly I used it in a library inside object, so when you brought two life multiple such objects
for $sth (@sth) { my $object=new STH; $objects{$sth}=$object; };
the whole shebang failed miserably (the last invocation of $object hides every other SSLeay::Handle (there is only one \*S2)
Now I'm trying to fix the code, here's my attempt which seems to work at the moment:
{my $io=new IO::Handle; tie(*$io, "Net::SSLeay::Handle", $socket);$so +cket = \*$io;}; { my $io=new IO::Handle; tie(*$io, "Net::SSLeay::Handle", $socket); $socket = \*$io; };
AFAIK this works because every $io=new IO::Handle generates unique identifier, so my code above might be replaced with
and it would still work, and wouldn't depend on chance (I hope two IO::Handle->new()don't get the same identifier).$global-net-ssleay-counter++; tie(*$global.....
What is the proper solution to this? How should I use Net::SSLeay::Handle?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Globs and globals
by BrentDax (Hermit) on Jan 25, 2005 at 07:58 UTC | |
by Eyck (Priest) on Jan 25, 2005 at 13:48 UTC | |
by BrentDax (Hermit) on Jan 25, 2005 at 18:40 UTC | |
by Eyck (Priest) on Jan 26, 2005 at 06:34 UTC | |
by BrentDax (Hermit) on Jan 26, 2005 at 10:29 UTC | |
Re: Globs and globals
by nobull (Friar) on Jan 25, 2005 at 12:39 UTC | |
Re: Globs and globals
by dragonchild (Archbishop) on Jan 25, 2005 at 14:09 UTC |