Syntax error on use Cwd qw(abs_path);

Syntax error on use Cwd qw(abs_path);

am 26.05.2011 20:10:32 von Derek

Hello, I am getting the following error:

bash: /var/www/html/bugzilla/email_in.pl: line 2: syntax error near
unexpected token `('
bash: /var/www/html/bugzilla/email_in.pl: line 2: `use Cwd
qw(abs_path);'

The contents of this file are:

#!/usr/bin/perl
use Cwd qw(abs_path);

Thats all. I know basically nothing about perl. I am a Java programmer
mostly. I am getting this same problem in the bugzilla email_in.pl
scripts. So I trimmed it down to the shortest amount of lines that
seem to be the problem. I tried to look up what the lines are doing
but I cant figure it out why its complaining of an error.

I can run this on the command line with no errors:

perl -e 'use Cwd qw(abs_path);'

Why would I not be able to run this in a script but I can on the
command line?

Thanks.


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Syntax error on use Cwd qw(abs_path);

am 28.05.2011 21:10:38 von Uri Guttman

>>>>> "D" == Derek writes:

D> Hello, I am getting the following error:
D> bash: /var/www/html/bugzilla/email_in.pl: line 2: syntax error near
D> unexpected token `('

big clue. what is the first word of that line? it is bash! perl is not
seeing your script for some reason. so this is not a perl issue but a
bash one. find out why bash is running your file instead of perl.

uri

--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Syntax error on use Cwd qw(abs_path);

am 28.05.2011 22:26:12 von Bob goolsby

--bcaec548a6cd84af0504a45bdde4
Content-Type: text/plain; charset=ISO-8859-1

Mornin' --

Derek Said:
>>>
The contents of this file are:

#!/usr/bin/perl
use Cwd qw(abs_path);
>>>

If the first line is indeed a blank line, then the default interpreter is
invoked. The '#!' has to the the first two characters on the first line of
your code.

B

On Sat, May 28, 2011 at 12:10 PM, Uri Guttman wrote:

> >>>>> "D" == Derek writes:
>
> D> Hello, I am getting the following error:
> D> bash: /var/www/html/bugzilla/email_in.pl: line 2: syntax error near
> D> unexpected token `('
>
> big clue. what is the first word of that line? it is bash! perl is not
> seeing your script for some reason. so this is not a perl issue but a
> bash one. find out why bash is running your file instead of perl.
>
> uri
>
> --
> Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com--
> ----- Perl Code Review , Architecture, Development, Training, Support
> ------
> --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com---------
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
>
>
>


--

Bob Goolsby
bob.goolsby@gmail.com

--bcaec548a6cd84af0504a45bdde4--

Re: Syntax error on use Cwd qw(abs_path);

am 31.05.2011 16:44:29 von Jim Gibson

At 11:10 AM -0700 5/26/11, Derek wrote:
>Hello, I am getting the following error:
>
>bash: /var/www/html/bugzilla/email_in.pl: line 2: syntax error near
>unexpected token `('
>bash: /var/www/html/bugzilla/email_in.pl: line 2: `use Cwd
>qw(abs_path);'
>
>The contents of this file are:
>
>#!/usr/bin/perl
>use Cwd qw(abs_path);
>
>Thats all. I know basically nothing about perl. I am a Java programmer
>mostly. I am getting this same problem in the bugzilla email_in.pl
>scripts. So I trimmed it down to the shortest amount of lines that
>seem to be the problem. I tried to look up what the lines are doing
>but I cant figure it out why its complaining of an error.
>
>I can run this on the command line with no errors:
>
>perl -e 'use Cwd qw(abs_path);'
>
>Why would I not be able to run this in a script but I can on the
>command line?

Because bash is not running the Perl interpreter, but trying to
execute the file as bash commands. That is why the first part of each
error line is "bash:". Something is wrong with your first line. Try
this:

perl /var/www/html/bugzilla/email_in.pl: line 2: syntax error near

and see what you get.


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/