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

I have just started using perl and am writing my first program. The problem being (and I know there is going to be an obvious solution that'll make me feel silly), when I run it and it compiles I get the following.
syntax error at line 4 : ')' unexpected
Line 4 reads ...
open(CLI, "database_dump");
I have tried removing the brackets and it picks up the next set of brackets as an error. This next line reads ...
While(<CLI>)
Do I have include something or alter my PATH or what ??? Getting v. frustrated !!! Can anybody help ... cheers Rich

Replies are listed 'Best First'.
Re: Beginner needs help
by azatoth (Curate) on Jun 14, 2001 at 14:13 UTC
Re: Beginner needs help
by virtualsue (Vicar) on Jun 14, 2001 at 15:27 UTC
    Do you have a line like this at the top of your script?

    #!/path/to/perl -w  # This line tells your shell to use Perl to run your script

    If not, then that's likely to be the problem. We'll need to see the code to be certain, but I think that your problem may be a missing or broken shebang at the top of your script. On unix, the custom is for a /bin/sh to be fired up to run your script if the #! line is missing. Feeding Perl to a bourne shell usually gives it heartburn right away. :)

Re: Beginner needs help
by Brovnik (Hermit) on Jun 14, 2001 at 14:12 UTC
    If the code is only a few lines, you are better to include more context, since the error may be triggered by previous lines.

    are you using strict and warnings ?

    "While" should be "while". I think this is your main problem, since PERL thinks this is a call to a function rather than a while statement, so the {} following the While causes the error.

    You should also be checking the result of the open in case it fails.
    --
    Brovnik

Re: Beginner needs help
by Jonathan (Curate) on Jun 14, 2001 at 15:49 UTC
    If you are using Unix is your file executable? The error message looks very much like a ksh one.