Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Module not returning a true value

Status
Not open for further replies.

Loon

Programmer
May 24, 2000
100
GB
What's all this about?? <br><FONT FACE=monospace><br>$ ./trace_test.pl<br>TRACING.pm did not return a true value at ./trace_test.pl line 4.<br>BEGIN failed--compilation aborted at ./trace_test.pl line 4.<br>$<br></font><br><br>I have exported my functions and variables using the @EXPORT thing.. I copied an example module and then modified it with my code. But when my test script above tries to run a function I get the error message above.<br><br>Is this a silly syntactical error? Or does it mean something more serious?<br><br>Cheers!<br>Loon
 
When you include a module in your perl program, the module (.pl or .pm) must always return a value of <FONT FACE=monospace>true</font>.&nbsp;&nbsp;Any other value indicates that the module has failed in some way.&nbsp;&nbsp;For example, a compilation problem, or you may have initialisation code in the module that has failed and manually return a value of <FONT FACE=monospace>false</font>.<br><br>I don't have any experience with writing &quot;modern&quot; (;^) .pm style OOP modules, as I usually just create function libraries.&nbsp;&nbsp;ie, a seperate perl file just containing various functions.&nbsp;&nbsp;At the end of each &quot;function library&quot;, I simply enter &quot;1;&quot; on a line on it's own at the end of the file.<br><br>Try doing the same with your module, it should get rid of that error message you are receiving. <p> <br><a href=mailto: > </a><br><a href= > </a><br>--<br>
0 1 - Just my two bits
 
Cheers, it has indeed. I finally decided to download some<br>modules from the net and after looking through found the <font color=red>1;</font>s at the bottom of each file. I tried it and lo and behold it worked!<br><br>Thanks for the explanation, no books or tutorials I've seen have given any indication of requiring a return value and stuff.<br><br>Thanks again!<br>Loon
 
Showing my age a little, I think it was in the original &quot;pink book&quot; version of Programming Perl.&nbsp;&nbsp;I'm not 100% sure that I've seen it in the 2nd edition, but I'll check tonight.<br><br>Glad it worked for you, though. :) <p> <br><a href=mailto: > </a><br><a href= > </a><br>--<br>
0 1 - Just my two bits
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top