F
Foo Bar
Singleton.pm:
=============
package Singleton;
my $instance = undef;
sub new
{
if (!defined $instance) {
$instance->{count} = 0;
bless($instance, 'Singleton');
}
return $instance;
}
1;
Obj.pm:
=======
package Obj;
use Singleton;
@Obj::ISA = qw(Singleton);
sub count {
my $self = shift;
return $self->{count}++;
}
1;
test.pl:
========
#!/usr/bin/perl -w
use Obj;
my $obj = new Obj;
print $obj->count, "\n";
Friggin' error:
===============
Can't locate object method "count" via package "Singleton" at test.pl line 60.
Even I tried to throw in Singleton as follow and it didn't help:
BEGIN
{
use Exporter ();
@Singleton::ISA = qw(Exporter);
}
Dang...I'm too tired to figure out what goes wrong!!!!
=============
package Singleton;
my $instance = undef;
sub new
{
if (!defined $instance) {
$instance->{count} = 0;
bless($instance, 'Singleton');
}
return $instance;
}
1;
Obj.pm:
=======
package Obj;
use Singleton;
@Obj::ISA = qw(Singleton);
sub count {
my $self = shift;
return $self->{count}++;
}
1;
test.pl:
========
#!/usr/bin/perl -w
use Obj;
my $obj = new Obj;
print $obj->count, "\n";
Friggin' error:
===============
Can't locate object method "count" via package "Singleton" at test.pl line 60.
Even I tried to throw in Singleton as follow and it didn't help:
BEGIN
{
use Exporter ();
@Singleton::ISA = qw(Exporter);
}
Dang...I'm too tired to figure out what goes wrong!!!!