I followed the Rose::DB::Object tutorial on CPAN and set up three packages.
package My::DB::Object;
use My::DB;
use base qw(Rose::DB::Object);
sub init_db { My::DB->new }
package My::DB;
use base qw(Rose::DB);
...
package Motorcycle;
use base 'My::DB::Object';
__PACKAGE__->meta->setup
(
...
);
__PACKAGE__->meta->make_manager_class('motorcycles');
In the application:
package main;
use Motorcycle;
use Mojolicious::Lite;
This failed to compile with this error:
My/DB/Object did not return a true value <eval 2> line 2…
Regards and thanks.
While I can't say I fully understand what it is you are trying to accomplish, the error you are seeing is a fairly common one. Any file/module that is included with a use
or require
must return a "true" value. This is usually accomplished by ending that file with the line 1;
, that is to say simply a command that is true (as opposed to 0 being false). Look at any other file ending in .pm on your system and it is likely to end this way.
You can also read more in perldoc perlmod
, or there is this statement from perldoc -f require
:
The file must return true as the last statement to indicate successful execution of any initialization code, so it's customary to end such a file with "1;" unless you're sure it'll return true otherwise. But it's better just to put the "1;", in case you add more statements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With