in reply to Re: Syntax Error
in thread Syntax Error

Sorry about the 'a'. How do I feed it to perl? I thought I just had to place the statement: #!/usr/bin/perl -w in the script. Eudoro

Replies are listed 'Best First'.
Re: Re: Re: Syntax Error
by Old_Gray_Bear (Bishop) on Jan 20, 2004 at 16:28 UTC
    There are a couple of possibilities here.

    1 -- The 'shebang line' ("#! /user ...") may have a leading space. The Shell, not finding '#!' as the first two characters takes off an tries to parse/run the "ksh" script it has just discovered.

    2 -- The first line in the file is empty, so the Shell having no other guidance takes off and fails during the parse.

    ----
    I Go Back to Sleep, Now.

    OGB

      The handling of #! as the first two bytes of the file is a kernel issue. It's the kernel that looks at the first couple of bytes of an executable, and then decides how to run it. When issued properly, no shell will be involved. In fact, if the program gets fed to the shell, the first line will be ignored. # is, afterall, the start of a comment.

      Abigail

      A third (unlikely) possibility is that Eudoro is executing the script on the commandline as follows
      $ ksh my_script.pl

      As I said, unlikely, but possible.

      ------
      We are the carpenters and bricklayers of the Information Age.

      Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Re: Syntax Error
by Abigail-II (Bishop) on Jan 20, 2004 at 16:48 UTC
    Placing a she-bang line is only half the trick - the kernel must also sniff at it. How are you calling your program, and what are its execution bits?

    Abigail

      I am executing it using: . ./test.pl
        Well, that's wrong. You are telling your current shell to execute the program in the current shell (without a fork). Remove the first dot.

        Abigail