jcpunk has asked for the wisdom of the Perl Monks concerning the following question:

I've done a bit of OO programing in perl, but never had an error looking anything like
./thing.pl did not return a true value at ./test_prog.cgi line 4.
after googling around for a bit and consulting thepen, I post this here hopeing for hints as to whats up.
./test_prog.cgi is able to use the same require line on a different perl library ive got written with no problems, but nothing seems to be able to include ./thing.pl.

thanks for any hints you can toss my way


jcpunk
all code is tested, and doesn't work so there :p (varient on common PM sig for my own ammusment)

Replies are listed 'Best First'.
Re: OO problem showing i am a newbie at OO
by tachyon (Chancellor) on Dec 13, 2003 at 06:00 UTC
      thanks for the tip, it works now (minus a few syntax errors that just showed up)

      jcpunk
      all code is tested, and doesn't work so there :p (varient on common PM sig for my own ammusment)
Re: OO problem showing i am a newbie at OO
by Zaxo (Archbishop) on Dec 13, 2003 at 05:48 UTC

    I can't tell whather your tried to use or require, but did you try checking whether thing.pl has a true value as its last statement?

    After Compline,
    Zaxo

      It is a very common practice (and one you'll even find demonstrated in Programming Perl, the Camel book) to put a  1; as the last line of your module so that the module returns true. Try it and see if that clears up your problem.

      Update: To clarify, I just wanted to quote the relevant statement out of Advanced Perl Programming (the Panther book):

      When a file is require'd or use'd, it is expected to return a Boolean success value (zero for failure, nonzero for success). That is, the last executing statement at global scope must be a statement such as "return 1;" or just "1;". Note that this is not necessarily the last statement in the file; it is just the last executing statement.


      Dave

Re: OO problem showing i am a newbie at OO
by ambrus (Abbot) on Dec 13, 2003 at 13:12 UTC

    This error is explained correctly in perldoc perldiag. You should read this pod whenever you get an error message from perl core you don't understand. Most messages are described well there.

      Ah ha, I will be checking that out, thanks

      jcpunk
      all code is tested, and doesn't work so there :p (varient on common PM sig for my own ammusment)