Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comments break my code

by arcnon (Monk)
on Nov 19, 2005 at 16:50 UTC ( [id://510116]=perlquestion: print w/replies, xml ) Need Help??

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

a module I wrote breaks when I add a comment line

if I place '# test' anywhere inside my module I get :

Tester/Test.pm did not return a true value at ./t.pl line 7.
BEGIN failed--compilation aborted at ./t.pl line 7.

I have the '1;' at the end of the module. I can also comment the script that calls the module with no problems. I have never had anything like this happen before and has taken 6 hours just to find out what was causing my error.

If I remove the comment it works fine.

running perl This is perl, v5.8.6 built for darwin

Can someone please help me!

Replies are listed 'Best First'.
Re: comments break my code
by Tanktalus (Canon) on Nov 19, 2005 at 16:55 UTC

    arcnon, it would be extremely helpful if you could show a piece of code the replicates the problem. Off the top of my head, you may be using a source filter, even if you don't realise that you are (what modules are you useing inside this module?).

      this is it

      t.pl

      #!/usr/bin/perl -w use strict; use CGI; use Tester::Test; Tester::Test->test();
      Test.pm
      package Tester::Test; use strict; sub test{ print "test"; } #test 1; __END__
        If you're editing files on Windows and running them on a Mac, you might need to check your line endings -- is there a real carriage-return between the comment and the "1;" line? -Simon

        Hi,

        A thing that has nothing to do with your problem, but I won't use the indirect method call when you're not dealing with OO. Tester::Test->test() Because that way your first argument in the @_ array will be the Package name 'Tester::Test'.

        Use the normal method Tester::Test::test() or use the Exporter module to import the subroutines into your namespace.

        Tester::Test.pm
        package Tester::Test; use strict; use Exporter qw/ import /; our @EXPORT_OK = qw/ test /; sub test{ print "test"; } 1;
        t.pl
        #!/usr/bin/perl -w use strict; use CGI; use Tester::Test qw/test/; # if you want to import it into your namesp +ace Tester::Test::test(); # or directly test() if you have imported it exit;

        Regards,

        |fire| at irc.freenode.net

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://510116]
Approved by Tanktalus
Front-paged by gmax
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-16 15:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found