Subject: | Moose doesn't work in "main" script(?) |
Date: | Wed, 24 Mar 2010 06:47:39 -0700 (PDT) |
To: | bug-moose [...] rt.cpan.org |
From: | Eugene Lukianov <eugene_l_a [...] yahoo.com> |
Dear Moose Supporters:
I'm new to Moose so, perhaps, this is a silly question. When I run the following script: (everything is in one file):
#!/usr/bin/perl -w
use Data::Dump qw(dump);
my $ip = InnerPackage->new;
print "\n\nInnerPackage dump: ",
dump($ip),"\n";
print "InnerPackage attr: ",$ip->{attr},"\n";
print "InnerPackage t returns: ",$ip->t,"\n";
exit;
package InnerPackage;
use Moose;
with 'Non::Existent';
has 'attr' => (
default => 'Some value',
);
sub t { return "test sub" }
1;
# ------- End of file -------
Moose does not complain it cannot find "Non::Existent.pm" module, instead it just returns empty instance of InnerPackage object and the script prints:
InnerPackage dump: bless({}, "InnerPackage")
Use of uninitialized value in print at ./testMoose.pl line 7.
InnerPackage attr:
InnerPackage t returns: test sub
However, when I place "package InnerPackage;" definition to a separate InnerPackage.pm file and "use InnerPackage;", Moose complains it cannot find "Non::Existent.pm" module in "with 'Non::Existent';" statement. When I replace "Non::Existent" with some existing module, Moose correctly inherits from it.
Could you please let me know if this is a bug in Moose or am I doing something wrong. Any help is greatly appreciated - I really need to place local module in a "main" perl script.
Thank you in advance for your help and sorry for troubling you with this. I look forward for your earliest reply.
Best regards,
Eugene A.Lukianov.