Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Singleton and unblessed refereces.

by rjt (Deacon)
on Jul 08, 2013 at 12:16 UTC ( #1043104=note: print w/ replies, xml ) Need Help??


in reply to Singleton and unblessed refereces.

Works for me with dummy objects:

test.pl:

#!/usr/bin/env perl use 5.012; use warnings; use myDebugger; my $instance = myDebugger::GetInstance(); say ref($instance); $instance->{foo} = 'Persistent'; # Ensure we get same instance my $instance_ref2 = myDebugger::GetInstance(); say ref($instance_ref2); say $instance_ref2->{foo};

myDebugger.pm:

package myDebugger; use 5.012; use warnings; my $debugger; sub GetInstance { return $debugger //= bless { foo => 'bar' }, 'OLEThingy'; } 1;

Output:

OLEThingy OLEThingy Persistent

I suggest you eliminate this code and focus on the object in question; boil it down to a small test case, and the problem might solve itself, or you can of course come back here armed with more information.


Comment on Re: Singleton and unblessed refereces.
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043104]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2015-07-05 03:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls