Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Syntax Error Messages (was: Beginner needs help (in more ways than one !))

by richmusk (Novice)
on Jun 14, 2001 at 14:02 UTC ( [id://88344]=perlquestion: print w/replies, xml ) Need Help??

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>)
Which must need brackets surely !

Do I have include something or alter my PATH or what ??? Getting v. frustrated !!!

Can anybody help ...

cheers Rich

2001-06-16 Edit by Corion : Changed title to be more descriptive

Replies are listed 'Best First'.
Re: Beginner needs help (in more ways than one !)
by davorg (Chancellor) on Jun 14, 2001 at 14:06 UTC

    It looks like the error isn't on line 4 of your code, but compilers can sometimes get a bit confused about line numbers.

    I'm willing to bet that there's something wrong a bit higher up in your program. Can you show us the first dozen or so lines.

    --
    <http://www.dave.org.uk>

    Perl Training in the UK <http://www.iterative-software.com>

Beginner needs more help
by richmusk (Novice) on Jun 14, 2001 at 15:02 UTC
    Ok .. I have been requested to provide more info ... here is the first part of my program ...
    #!/home/freetool/bin/perl5 open(CLI,"datablitz_dump") or die "datablitz_dump not found\n"; $iline = 0; while(<CLI>) { if (/^Dn:/) { $iline++; # ($dn1)= $_ =~ /^Dn: \w+ (\w+ = \d+)/; $trav=$_; $nbwd = ($trav =~ s/(\w+\s+=\s+\d+)//g); $trav=$_; $trav=~ s/Dn: //; $walknbwd[$iline][0] = $nbwd; for ($i=1;$i<=$nbwd;$i++) { # ($bid,$dns[$i-1]) = ($trav =~ /(\w+\s+(\w+\s+=\s+\d+),*\s*){$i} +/); ($bid1,$bid2,$walkdns[$iline][$i-1],$walkdnval[$iline][$i-1]) = +($trav =~ /(\w+\s+((\w+)\s+=\s+(\d+)),*\s*){$i}/); }
    I get the following syntax error during compliation
    perlprog[3]: syntax error at line 3: '(' unexpected
    If I replace line 3 with open CLI, "database_dump"; I get the following errors during compliation
    perlprog[3]: open: not found perlprog[5]: =: not found perlprog[7]: syntax error at line 7: ')' unexpected
    I know this works in theory but I can't seem to run it on my machine ... my machine is the problem I think but I don't know why ...

    Ta

    Rich

      There must be something wrong with your shebang line as these are are the errors that you get when a perl script is run by the shell rather than by perl.

      Is there actually a file at /home/freetool/bin/perl5? Is it a valid Perl interpreter? What do you get if you type

      perl -v /home/freetool/bin/perl5

      Also worth checking that there are no spurious invisible characters added to the end of the shebang line.

      Oh, and when adding more info like this, you'd usually add it as a follow-up to the original node.

      --
      <http://www.dave.org.uk>

      Perl Training in the UK <http://www.iterative-software.com>

Re: Beginner needs help (in more ways than one !)
by tune (Curate) on Jun 14, 2001 at 15:21 UTC
    Try to type your keywords in lowercase:
    while (<CLI>) { ... }
    (not While)

    --
    tune

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://88344]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2025-05-14 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.