Error & quot

G

geek

Hi all,

I am getting following error when I try to run the script a part of
which is shown below.

Error:<PRE>syntax error at sem_reg_test.cgi line 192, near &quot;|| die
&quot;$0&quot;

Any help will be appreciated.

Thanks,
MJ

=========================================================================
else {
open(COURSEINFO,$coursefile)
|| die "$0: Could not read course information ($coursefile):
$!\n";

# flock(COURSEINFO, 1);

while (<COURSEINFO>) {
# remove trailing newline
chomp;

# save comments and blank lines
if (/^#/ || /^\s*$/) {
push(@courses_new, $_);
next;
}
 
G

geek

Sorry for the confusion .
I have specified the line # in the code.
Exactly even I don't see any $quot in my script infact I know there is
no $quot in the script.

Thanks,
 
J

John Bokma

geek said:
Hi all,

I am getting following error when I try to run the script a part of
which is shown below.

Error:<PRE>syntax error at sem_reg_test.cgi line 192, near &quot;|| die
&quot;$0&quot;

And which line is 192?
 
G

geek

Here is the code with line number in it :

else {
open(COURSEINFO,$coursefile)
line:192 || die "$0: Could not read course information ($coursefile):

# flock(COURSEINFO, 1);
 
T

Tad McClellan

Exactly even I don't see any $quot in my script infact I know there is
no $quot in the script.


There is no $quot in the message either, so I don't know why
you are speaking of it...
 
T

Tad McClellan

geek said:
I am getting following error when I try to run the script a part of
which is shown below.

Error:<PRE>syntax error at sem_reg_test.cgi line 192, near &quot;|| die
&quot;$0&quot;


Carp is adding the &quot; entities, the message is supposed to look
like this:

syntax error at sem_reg_test.cgi line 192, near "|| die "$0"

(but that looks like one extra quote to me...)

else {
open(COURSEINFO,$coursefile)
|| die "$0: Could not read course information ($coursefile):
$!\n";


That looks OK to me, the problem must be in the lines preceding
those that you have shown us.

There is no extra quote there, it seems that the code and the
error message do not match...
 
T

Tony Curtis

[ top-posting rearranged ]
Sorry for the confusion . I have specified the line # in
the code. Exactly even I don't see any $quot in my script
infact I know there is no $quot in the script.

That's probably an attempt at returning HTML to you, but
without the HTTP headers to identify it as such so the browser
you're viewing the output in isn't rendering it.

You'll need to show the context of the code, I'd suggest about
10 lines either side of the indicated line. Show the code
with line numbers, e.g. as output by "cat -n".

hth
t
 
G

geek

Here is the code that is giving the error
I have marked line 191.
The error I get is
<PRE>syntax error at sem_reg_test.cgi line 191, near &quot;open
(COURSEINFO, &qu
ot;$coursefile&quot;
Global symbol &quot;$item&quot; requires explicit package name at
sem_reg_test.c
gi line 230.
Global symbol &quot;$item&quot; requires explicit package name at
sem_reg_test.c
gi line 230.

################################################################################
# Reads in course information from file
sub read_course_info {
my @allcourse = ("basic_mtx.data","packet_mtx.data") ;
# Checking the directory for available courses
if($set eq "all")
{
foreach my $mycourse(@allcourse){
open (AllINFO, "data/$mycourse")
|| die "$0: could not read course information:$!;
while(<ALLINFO>){
# removing trailing newline
chomp;

# Save comments and blank lines
if(/^#/ || /^\s*$/){
push(@courses_new, $_);
next;
}
#accumulate list of courses
push(@courses,$_);
}
close(ALLINFO);
}

else {

Line 191 :eek:pen (COURSEINFO, "$coursefile")
|| die "$0:could not read course information ($coursefile):
$!\n";

# flock(COURSEINFO, 1);

while (<COURSEINFO>) {
# remove trailing newline
chomp;

# save comments and blank lines
if (/^#/ || /^\s*$/) {
push(@courses_new, $_);
next;
}

# accumulate list of courses
push(@courses, $_);
}

close(COURSEINFO);

}
}
################################################
Any help will be appreciated.

Thanks,
MJ
 
T

Tad McClellan

geek said:
The error I get is
<PRE>syntax error at sem_reg_test.cgi line 191, near &quot;open
(COURSEINFO, &qu
ot;$coursefile&quot;

open (AllINFO, "data/$mycourse")
|| die "$0: could not read course information:$!;
^
^

Where is the closing quote?

Line 191 :eek:pen (COURSEINFO, "$coursefile")


perldoc -q vars

What's wrong with always quoting "$vars"?

so that should be

open (COURSEINFO, $coursefile)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top