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

I am having trouble importing modules (ie. "use CGI;") when I try to import any module I get the following error, syntax error in file test.pl at line 4, next 2 tokens "use CGI" Execution of test.pl aborted due to compilation errors. Does anyone know what might cause this. James

Replies are listed 'Best First'.
(tye)Re: Importing modules
by tye (Sage) on Jan 15, 2001 at 23:46 UTC

    Sounds like Perl 4, which didn't have a use function.

            - tye (but my friends call me "Tye")
Re: Importing modules
by c-era (Curate) on Jan 15, 2001 at 23:47 UTC
    It sounds like you are using perl 4. Can you let us know what version of perl you are using. If you are using perl 5 there may be something wrong before use CGI;, so please post a short example.
Re: Importing modules
by Fastolfe (Vicar) on Jan 15, 2001 at 23:47 UTC
    Generally it helps if you try to post the line of code giving you the problem, including one or two lines of context on either side. I think you'll find that you're missing a semi-colon at the end of line 3, or that there is some syntax error on that line.
Re: Importing modules
by myocom (Deacon) on Jan 15, 2001 at 23:47 UTC

    Could you post what test.pl is? It'll make it much easier to troubleshoot...

Re: Importing modules
by mr.nick (Chaplain) on Jan 15, 2001 at 23:47 UTC
    Could you share with us the exact script ("test.pl" in this case I'd imagine) that is causing the errors?
Re: Importing modules
by jamess (Initiate) on Jan 16, 2001 at 00:24 UTC
    I am using perl 5 and I am running it on HPUX 10.20, bellow is the code that gave me that error. #!/opt/perl5/bin/perl use CGI;

      Just to be sure, what does /opt/perl5/bin/perl -V result in?

      BTW, you should wrap your cut-and-pasted code in <code></code> tags to make it easier to read.

      I think anyone having trouble importing modules should probably take a step back from programming perl just now. If you can't grasp this simple concept, how do you seriously expect us to listen to you on PerlMonks? Come back when you have RTFM.