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

what do you think is wrong when the message appears:

script2.pl did return a true value at script1.pl line ...

Is it either with

"require" statement

in script1.pl or something wrong with the codes/algorithms?

Please help me figure out. Thank you in advance

Replies are listed 'Best First'.
Re: did not return a true value: what is wrong?
by bobf (Monsignor) on Nov 05, 2009 at 04:26 UTC

    Try adding

    1;
    to the end of the required file. See require for a bit of explanation about this.

    Modules must return a true value when they are used. See perlmod.

      Thanks for pointing me to the perlmod and perldoc

Re: did not return a true value: what is wrong?
by Anonymous Monk on Nov 05, 2009 at 08:02 UTC
    diagnostics, splain
    $ echo 0 >foo.pl $ perl -e"require q!foo.pl!;" foo.pl did not return a true value at -e line 1. $ perl -Mdiagnostics -e"require q!foo.pl!;" foo.pl did not return a true value at -e line 1 (#1) (F) A required (or used) file must return a true value to indicate + that it compiled correctly and ran its initialization code correctly. +It's traditional to end such a file with a "1;", though any true value +would do. See perlfunc/require. Uncaught exception from user code: foo.pl did not return a true value at -e line 1. at -e line 1 $ perl -e"require q!foo.pl!;" 2>&1 |splain foo.pl did not return a true value at -e line 1 (#1) (F) A required (or used) file must return a true value to indicate + that it compiled correctly and ran its initialization code correctly. +It's traditional to end such a file with a "1;", though any true value +would do. See perlfunc/require. $
Re: did not return a true value: what is wrong?
by apl (Monsignor) on Nov 05, 2009 at 13:18 UTC
    First of all, you did not get the message
    script2.pl did return a true value at script1.pl line ...

    Rather, you got
    script2.pl did not return a true value at script1.pl line ...
    which is the exact opposite.

    Had you tried Googling .pl did not return a true value at, you would have gotten 153,000 hits, the fifth of which (starting Perl beginners) would have taken you to your answer.