[comp.lang.perl] Novice problem: why is this a syntax error?

se12@cs.vu.nl (Software Engin 91) (10/29/90)

RTFM'd, but couldn't find why perl said:

syntax error at line 33: `else' unexpected.

at this fragment:

# Now, what is the main module anyway?
if ($#ARGV >= 0)
	{ $mainbase = $ARGV[0]; }
else
	{ $mainbase = "Main.mod"; }              <<< this is line 33
$mainbase =~ s/\.mod$//o;
$mainfile = $mainbase.".mod";

Sorry for this very stupid question, but this is my first perl script
that should actually do something useful (a Makefile generator for Modula-2).

-					Gerben.

se12@cs.vu.nl (Software Engin 91) (10/29/90)

Sorry.
I asked a question about an if {...} else {...} -construct which perl didn't
understand.
But i have found the error now. The first line of my perl script read
#/usr/local/bin/perl
...instead of:
#!/usr/local/bin/perl

So the file was being fed to sh (or maybe even csh), instead of perl.

Sorry for bothering you all.
It is my first perl script, after all.

-					Gerben.