perlquestion
gideondsouza
So I'm hoping to write a nice wrapper around the StackExchange Api. It's a little learning project.
I use module starter and this is my directory:
<pre>
.
├── Changes
├── MANIFEST
├── Makefile.PL
├── README
├── ignore.txt
├── lib
│ └── Net
│ ├── StackExchange
│ │ ├── V2
│ │ │ └── Answers.pm
│ │ └── V2.pm
│ └── StackExchange.pm
└── t
├── 00-load.t
├── boilerplate.t
├── manifest.t
├── pod-coverage.t
└── pod.t
</pre>
<u>Three</u> package files. I have the following code in each of the pm files.
<code>
###################
# Inside StackExchange.pm
###################
sub new {
return Net::StackExchange::V2->new();
}
###################
# Inside V2.pm
###################
sub new {
my ($class) = @_;
my $self = {};
bless $self, $class;
return $self;
}
sub answers {
return Net::StackExchange::V2::Answers->new();
}
###################
# Inside Answers.pm
###################
sub new {
my ($class) = @_;
my $self = {
auth_token => "",
};
bless $self, $class;
return $self;
}
sub getAll {
print "All Answers";
}
</code>
Here is <b>my problem</b>:
<code>
#########
# UsageTest.pl
#########
use lib("some_path_to_module/Net-StackExchange/lib");
use Net::StackExchange;
my $a = Net::StackExchange->new();
my $r = $a->answers->getAl();
print $r;
# Using Dumper..
print Dumper($r);
#returns => All Answers$VAR1 = 1
</code>
<p>The output I get is : <b>All Anwers<u>1</u></b></p>
<p>
I cannot figure out for the life of me where that <b>1 (one)</b> came from? Is it the one from the package returning 1? Doesn't make any sense to me!!</p>