Error & quot

Discussion in 'Perl Misc' started by geek, Feb 9, 2005.

  1. geek

    geek Guest

    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;
    }
    geek, Feb 9, 2005
    #1
    1. Advertising

  2. geek

    geek Guest

    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,
    MJ
    geek wrote:
    > 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)
    > line:192 || 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;
    > }
    geek, Feb 9, 2005
    #2
    1. Advertising

  3. geek

    John Bokma Guest

    John Bokma, Feb 9, 2005
    #3
  4. geek

    geek Guest

    Here is the code with line number in it :

    else {
    > open(COURSEINFO,$coursefile)
    > line:192 || 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;
    > }
    geek, Feb 9, 2005
    #4
  5. geek <> wrote:


    > 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...


    > geek wrote:


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

    > die
    >> &quot;$0&quot;




    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Feb 10, 2005
    #5
  6. geek <> wrote:

    > 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...


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Feb 10, 2005
    #6
  7. geek

    Tony Curtis Guest

    [ top-posting rearranged ]

    >> On 9 Feb 2005 14:36:54 -0800,
    >> "geek" <> said:


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

    > die
    >> &quot;$0&quot;
    >>


    > 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
    Tony Curtis, Feb 10, 2005
    #7
  8. geek

    geek Guest

    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
    geek, Feb 11, 2005
    #8
  9. geek <> wrote:

    > 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)


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Feb 11, 2005
    #9
  10. geek

    geek Guest

    Thanks so much for help.
    geek, Feb 11, 2005
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. martin

    xmldocument &quot; and "

    martin, Mar 6, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    512
    martin
    Mar 7, 2004
  2. Phil Winstanley [Microsoft MVP ASP.NET]

    Re: validateRequest=&quot;false&quot; not working in web.config or page directive

    Phil Winstanley [Microsoft MVP ASP.NET], May 16, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    637
    Phil Winstanley [Microsoft MVP ASP.NET]
    May 16, 2004
  3. usr2003
    Replies:
    4
    Views:
    578
    usr2003
    Sep 19, 2003
  4. Frank Schmitt
    Replies:
    0
    Views:
    484
    Frank Schmitt
    Oct 14, 2003
  5. Ahti Legonkov
    Replies:
    0
    Views:
    497
    Ahti Legonkov
    Dec 12, 2003
Loading...

Share This Page