×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Module not returning a true value

Module not returning a true value

Module not returning a true value

(OP)
What's all this about??

$ ./trace_test.pl
TRACING.pm did not return a true value at ./trace_test.pl line 4.
BEGIN failed--compilation aborted at ./trace_test.pl line 4.
$


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.

Is this a silly syntactical error? Or does it mean something more serious?

Cheers!
Loon

RE: Module not returning a true value

When you include a module in your perl program, the module (.pl or .pm) must always return a value of true.  Any other value indicates that the module has failed in some way.  For example, a compilation problem, or you may have initialisation code in the module that has failed and manually return a value of false.

I don't have any experience with writing "modern" (;^) .pm style OOP modules, as I usually just create function libraries.  ie, a seperate perl file just containing various functions.  At the end of each "function library", I simply enter "1;" on a line on it's own at the end of the file.

Try doing the same with your module, it should get rid of that error message you are receiving.




--
0 1 - Just my two bits

RE: Module not returning a true value

(OP)
Cheers, it has indeed. I finally decided to download some
modules from the net and after looking through found the 1;s at the bottom of each file. I tried it and lo and behold it worked!

Thanks for the explanation, no books or tutorials I've seen have given any indication of requiring a return value and stuff.

Thanks again!
Loon

RE: Module not returning a true value

Showing my age a little, I think it was in the original "pink book" version of Programming Perl.  I'm not 100% sure that I've seen it in the 2nd edition, but I'll check tonight.

Glad it worked for you, though. :)




--
0 1 - Just my two bits

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close