http://www.perlmonks.org?node_id=194983

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

in my quest to learn perl, i've gone to the code section of this site and have read through some of the programs there in hopes to gain a better understanding of how real perl programs are written, in won such visit i came across a gameAI written by Falkkin. I thought that it was a really cool program and downloaded it so i could play with it. but to my disappointment it didn't work. woe is me :( i got a compile time error saying the module TicTacToe.pm returned a not true value. i've looked at the code over and over again and i can't find any reason why it would do such a thing. my only conclusion is it has to be my system or the perl interpretor causing the error. I'm running Win2000 and ActivePerl

Thanks for any help offered

jjdraco

Replies are listed 'Best First'.
Re: Perl Module returning a not true value
by Zaxo (Archbishop) on Sep 04, 2002 at 05:45 UTC

    The true value the module is expected to return is on line 374 of the listing at A simple game AI that learns. The remainder of the file is a demo program which may either be clipped to a separate file or have package main; added to it where it stands. How have you installed the program and modules?

    The way the demo is written, the Modules should each be clippeed and saved as ModName.pm in the same directory as the demo (assuming ActivePerl has . in the lib search path). Each should end with the 1; as the last line of perl in the file.

    After Compline,
    Zaxo

Re: Perl Module returning a not true value
by sauoq (Abbot) on Sep 04, 2002 at 05:47 UTC

    Check to be sure that you properly copied TicTacToe.pm. Make sure your copy ends with the line:

    1;

    -sauoq
    "My two cents aren't worth a dime.";
    
      ok i see, i deleted that line thinking it was nothing. so all that line does is return a true value? Is that line always in a module?

      thanks

      jjdraco
        so all that line does is return a true value?

        Yes.

        Is that line always in a module?

        Almost always. As you discovered, the module has to return a true value when it is loaded. By convention, modules are usually ended with a "1;" to ensure that the required true value is returned. Any true value will do though.

        -sauoq
        "My two cents aren't worth a dime.";
        
Re: Perl Module returning a not true value
by greenFox (Vicar) on Sep 04, 2002 at 08:04 UTC

    Zaxo and sauog have covered how to get gameAI going, if you want to find out some more about modules see tachyon's excellent Simple Module Tutorial

    Yeah I've been reffering to this tutorial a bit lately :)

    --
    Until you've lost your reputation, you never realize what a burden it was or what freedom really is. -Margaret Mitchell