What am I doing wrong here?
What am I doing wrong here?
am 30.08.2007 12:10:45 von Steve Horn
On Windows Active State perl whenever I try to run the program "print
("Hello World.\n");"; I keep getting the error messages "Bareword found
where operator expected at - line 1 near "print (Hello"" (missing
operator before Hello?), String found where operator expected at - line
1 near ""print ("" (Missing semicolon on previous line?), and String
found where operator expected at - line near "n");"". What am I doing
wrong here and how do I fix this? TIA Steve
--
Steve Horn
kcom1989@fastmail.fm
--
http://www.fastmail.fm - The professional email service
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: What am I doing wrong here?
am 30.08.2007 13:27:22 von william.hoopes
Try
print "Hello World.\n";
-----Original Message-----
From: activeperl-bounces@listserv.ActiveState.com
[mailto:activeperl-bounces@listserv.ActiveState.com] On Behalf Of Steve
Horn
Sent: Thursday, August 30, 2007 6:11 AM
To: perl-beginners@yahoogroups.com; activeperl@listserv.ActiveState.com
Subject: What am I doing wrong here?
On Windows Active State perl whenever I try to run the program "print
("Hello World.\n");"; I keep getting the error messages "Bareword found
where operator expected at - line 1 near "print (Hello"" (missing
operator before Hello?), String found where operator expected at - line
1 near ""print ("" (Missing semicolon on previous line?), and String
found where operator expected at - line near "n");"". What am I doing
wrong here and how do I fix this? TIA Steve
--
Steve Horn
kcom1989@fastmail.fm
--
http://www.fastmail.fm - The professional email service
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: What am I doing wrong here?
am 30.08.2007 15:15:07 von Brian Raven
Steve Horn <> wrote:
> On Windows Active State perl whenever I try to run the program "print
> ("Hello World.\n");"; I keep getting the error messages "Bareword
> found where operator expected at - line 1 near "print (Hello""
> (missing operator before Hello?), String found where operator
> expected at - line 1 near ""print ("" (Missing semicolon on
> previous line?), and String found where operator expected at - line
> near "n");"". What am I doing wrong here and how do I fix this? =
Ah, I think I see what you are doing, although for the life of me I
can't imagine why you would think that would work. It seems that your
"program" is actually the following (it took a while to realise that the
extraneous quotes were actually part of your code, and not just for
quoting!)
"print ("Hello World.\n");";
This is parsed by perl as something like (i.e. a bit of guesswork on my
part as AS perl is not compiled with DEBUGGING):
"print (" - a string
Hello - a bareword - the error message says that an operator is expected
before this
World - another bareword
.. - operator
/ - operator
n - another bareword
");" - another string
Essentially, remove the extraneous quotes and semi-colon, or better
still, just:
print "Hello World.\n";
HTH
-- =
Brian Raven =
==================== =====3D=
================
Atos Euronext Market Solutions Disclaimer
==================== =====3D=
================
The information contained in this e-mail is confidential and solely for the=
intended addressee(s). Unauthorised reproduction, disclosure, modification=
, and/or distribution of this email may be unlawful.
If you have received this email in error, please notify the sender immediat=
ely and delete it from your system. The views expressed in this message do =
not necessarily reflect those of Atos Euronext Market Solutions.
Atos Euronext Market Solutions Limited - Registered in England & Wales with=
registration no. 3962327. Registered office address at 25 Bank Street Lon=
don E14 5NQ United Kingdom. =
Atos Euronext Market Solutions SAS - Registered in France with registration=
no. 425 100 294. Registered office address at 6/8 Boulevard Haussmann 750=
09 Paris France.
L'information contenue dans cet e-mail est confidentielle et uniquement des=
tinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee. Tou=
te copie, publication ou diffusion de cet email est interdite. Si cet e-mai=
l vous parvient par erreur, nous vous prions de bien vouloir prevenir l'exp=
editeur immediatement et d'effacer le e-mail et annexes jointes de votre sy=
steme. Le contenu de ce message electronique ne represente pas necessaireme=
nt la position ou le point de vue d'Atos Euronext Market Solutions.
Atos Euronext Market Solutions Limited Soci=E9t=E9 de droit anglais, enregi=
str=E9e au Royaume Uni sous le num=E9ro 3962327, dont le si=E8ge social se =
situe 25 Bank Street E14 5NQ Londres Royaume Uni.
Atos Euronext Market Solutions SAS, soci=E9t=E9 par actions simplifi=E9e, e=
nregistr=E9 au registre dui commerce et des soci=E9t=E9s sous le num=E9ro 4=
25 100 294 RCS Paris et dont le si=E8ge social se situe 6/8 Boulevard Hauss=
mann 75009 Paris France.
==================== =====3D=
================
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: What am I doing wrong here?
am 31.08.2007 18:37:28 von Andy_Bach
> On Windows Active State perl whenever I try to run the program
"print("Hello World.\n");";
command line scripts on winx is a pain. It doesn't handle quoting very
well. Note here you've got the script enclosing dbl quotes in the script
itself. Even on *nix you'll have troubles w/ that. On linux you could do
(note enclosing single quotes):
$ perl -e 'print("Hello world.\n");'
but on windows, you're better off just writing the script to a file and
working that way. Or changing your cmd.com to something more flexible ;->
(seriously, there is a bash etc. for winx).
a
Andy Bach
Systems Mangler
Internet: andy_bach@wiwb.uscourts.gov
VOICE: (608) 261-5738 FAX 264-5932
Committee, n.:
A group of men who individually can do nothing but as a group
decide that nothing can be done.
-- Fred Allen
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: What am I doing wrong here?
am 01.09.2007 01:16:15 von fzarabozo
----- Original Message -----
From: Andy_Bach@wiwb.uscourts.gov
To: Steve Horn
Subject: Re: What am I doing wrong here?
> command line scripts on winx is a pain. It doesn't handle quoting very
> well. Note here you've got the script enclosing dbl quotes in the script
> itself. Even on *nix you'll have troubles w/ that. On linux you could do
> (note enclosing single quotes):
> $ perl -e 'print("Hello world.\n");'
On windows is as much pain as on unix. On both you can scape them if
necessary:
perl -e "print(\"Hello world.\n\");"
> but on windows, you're better off just writing the script to a file and
> working that way. Or changing your cmd.com to something more flexible ;->
> (seriously, there is a bash etc. for winx).
On Windows you can do the same exact thing woth mo problems at all:
C:\>perl -e 'print("Hello world.\n");'
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: What am I doing wrong here?
am 01.09.2007 02:48:27 von Mark Mielke
This is a multi-part message in MIME format.
--===============1613135751==
Content-Type: multipart/alternative;
boundary="------------010309060508060904040307"
This is a multi-part message in MIME format.
--------------010309060508060904040307
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Paco Zarabozo A. wrote:
>> but on windows, you're better off just writing the script to a file and
>> working that way. Or changing your cmd.com to something more flexible ;->
>> (seriously, there is a bash etc. for winx).
>>
>
> On Windows you can do the same exact thing woth mo problems at all:
>
> C:\>perl -e 'print("Hello world.\n");'
>
If you do find yourself needing "" and '' within your command line, as I
have in the past, I refer you to one of Perl's more unique and useful
features:
C:\> perl -e "print qq(Hello World\n);"
Due to odd quoting rules, I suggest using "" on Windows, and '' on UNIX.
Choose to use qq() or q() instead of escaping for either.
Cheers,
mark
--
Mark Mielke
--------------010309060508060904040307
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Paco Zarabozo A. wrote:
type="cite">
but on windows, you're better off just writing the script to a file and
working that way. Or changing your cmd.com to something more flexible ;->
(seriously, there is a bash etc. for winx).
On Windows you can do the same exact thing woth mo problems at all:
C:\>perl -e 'print("Hello world.\n");'
If you do find yourself needing "" and '' within your command line, as
I have in the past, I refer you to one of Perl's more unique and useful
features:
C:\> perl -e "print qq(Hello World\n);"
Due to odd quoting rules, I suggest using "" on Windows, and '' on
UNIX. Choose to use qq() or q() instead of escaping for either.
Cheers,
mark
--
Mark Mielke
--------------010309060508060904040307--
--===============1613135751==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1613135751==--
Re: What am I doing wrong here?
am 01.09.2007 04:29:25 von Andy_Bach
:> Due to odd quoting rules, I suggest using "" on Windows, and '' on
UNIX. Choose to use qq() or q() instead of escaping for either.
Well, not trying to inflame the winx v *nix wars soYMMV but I've always
had troubles getting command line scripts to run in cmd.exe
C:\Documents and Settings\andy>perl -e 'print("Hello world.\n");'
C:\Documents and Settings\andy>
C:\Documents and Settings\andy>perl -e "print(\"Hello world.\n\");"
Hello world.
C:\Documents and Settings\andy>perl -e "print qq(Hello world.\n);"
Hello world.
Cutnpasted all 3 there produce the appropriate result on linux.
On *nix you can actually do multi-line programs from the command line,
as a inside of surrounding quotes doesn't end the command
# perl -e 'print "hello world\n";
print "goodbye quotes\n";
print "even in the
\tquote\n";
'
hello world
goodbye quotes
even in the
quote
#
A different issue on *nix is '$' interpolation. This works on winx
(note dbl quotes script surrounders):
perl -e "$hi = qq(Hello world.\n); print $hi"
but fails in linux as '$hi' gets replaced by whatever's in the shell's
'$hi' env var, probably nothing:
# perl -e "$hi = qq(Hello world.\n); print $hi"
syntax error at -e line 1, near "="
Execution of -e aborted due to compilation errors.
perl see's a script like:
= qq(Hello world.\n); print
You need to use single quotes to protect the program from being interpolated
# perl -e '$hi = qq(Hello world.\n); print $hi'
Hello world.
That one gets a different error on winx
C:\Documents and Settings\andy>perl -e '$hi = qq(Hello world.\n); print $hi'
Can't find string terminator "'" anywhere before EOF at -e line 1.
I think the semicolon acts as a line ending or comment, maybe? But this
is the sort of error that made me give up on winx cmd lines scripting.
a
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: What am I doing wrong here?
am 01.09.2007 04:46:27 von Bill Luebkert
Andy Bach wrote:
>
> That one gets a different error on winx
You mean cmd.exe - not win32. I run tcsh on Win32 with no such problem.
> C:\Documents and Settings\andy>perl -e '$hi = qq(Hello world.\n); print $hi'
> Can't find string terminator "'" anywhere before EOF at -e line 1.
>
> I think the semicolon acts as a line ending or comment, maybe? But this
> is the sort of error that made me give up on winx cmd lines scripting.
Again - it's all about what shell you use. Try a native port of tcsh or
bash - you'll seldom use cmd.exe again.
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: What am I doing wrong here?
am 01.09.2007 05:02:18 von Mark Mielke
Andy Bach wrote:
> :> Due to odd quoting rules, I suggest using "" on Windows, and '' on
> UNIX. Choose to use qq() or q() instead of escaping for either.
> Well, not trying to inflame the winx v *nix wars soYMMV but I've
> always had troubles getting command line scripts to run in cmd.exe
> C:\Documents and Settings\andy>perl -e 'print("Hello world.\n");'
The rules are different. Even on UNIX, CSH vs SH is different. Try
adding ! into your command line from CSH and see confusing results... :-)
csh> perl -e 'print !1'
1: Event not found.
It isn't UNIX vs Windows as much as knowing the rules of the shell you
are using.
For Windows, the rules are pretty simple. The only recognized quotes are
double quotes (""). Backslashes within quotes are passed through unless
an odd number of backslashes precede the closing double quote, in which
case, the double quote is considered escaped. If a %VARIABLE% occurs
anywhere in the string it is substituted with the environment variable
that it matches.
I'm too tired right now to describe the UNIX rules. CSH vs SH vs KSH vs
ZSH vs ... they are all slightly different.
Storing the script to a file is definitely best.
> A different issue on *nix is '$' interpolation. This works on winx
> (note dbl quotes script surrounders):
> perl -e "$hi = qq(Hello world.\n); print $hi"
Try:
C:\> perl -e "print %PATH%, qq(\n)"
Granted, %PATH% is less likely to be used in a Perl command line - but
the point remains that interpolation is a problem no matter which shell
you use. :-)
> That one gets a different error on winx
> C:\Documents and Settings\andy>perl -e '$hi = qq(Hello world.\n);
> print $hi'
> Can't find string terminator "'" anywhere before EOF at -e line 1.
> I think the semicolon acts as a line ending or comment, maybe? But
> this is the sort of error that made me give up on winx cmd lines
> scripting.
The history here is that cmd.exe has odd interpretation rules. First
off, cmd.exe does not know much about quotes, and definately knows
nothing about single quotes (''). As far as cmd.exe is concerned, you
are calling:
perl -e "'$hi" "=" "qq(Hello" "world.\n)"; print "$hi'"
On Windows, however, the calling shell (cmd.exe) does not break the
arguments up into argv. Instead, it passes the entire command line (up
to the newline or semicolon or a few other characters) to the program as
a single string. It is then up the program to break up the arguments as
it sees fit. Perl is based on Windows libc which emulates argv splitting
according to UNIX rules.
The effect of this is that you have cmd.exe using one set of rules, and
then perl.exe using a different set of rules. Where the rules are
compatible, behaviour is "expected". Where the rules are incompatible,
people can easily become confused if they do not know both rules.
Places where this can be a problem? Try doing shell globbing on Windows
and be confused as to why:
C:\> perl test.pl *.txt
Does not always work. CMD.EXE doesn't expand *.txt. This is up to the
program - perl.exe. If perl.exe does not expand it? It doesn't get expanded.
Some fun information for people to think about... :-)
Cheers,
mark
--
Mark Mielke
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: What am I doing wrong here?
am 17.09.2007 04:00:07 von gerry_lowry
[reposting with correct e-mail address, sorry for any inconvenience]
----- Original Message -----
To: William.Hoopes@L-3Com.com; "Steve Horn" ;
perl-beginners@yahoogroups.com; activeperl@listserv.ActiveState.com
Sent: Sunday, September 16, 2007 1:21 PM
Steve, It's your extra quotation marks. You may have copied a example of the the form
type "..........some example........" without the surrounding quotation marks,
but left in the surrounding quotation marks.
print "("Hello World.\n");"; # not correct; two superfluous quotes; the superfluous semi-colon is effectively a null statement
^ ^^
print ("Hello World.\n"); # correct -- function form
print "Hello World.\n"; # simpler -- operator form
"An alternative way to look at functions is to say that they are all
either named unary operators (taking a single argument) or
named list operators (taking a list of arguments). How we describe them
then becomes a case of how we use them: if we use parentheses, they are functions, and
if we do not, they are (or at least, resemble) operators" Chapter 4 - Operators
--Professional PERL Programming, Simon Cozens, Arthur Corliss et al. Apress (c)2004
---------- example:
C:\!!!!perl>type whatWrongDoingHere.pl
print ("Hello World.\n");
C:\!!!!perl> whatWrongDoingHere.pl
Hello World.
C:\!!!!perl>type whatWrongDoingHere2.pl
print "("Hello World.\n");";
C:\!!!!perl> whatWrongDoingHere2.pl
Bareword found where operator expected at C:\!!!!perl\whatWrongDoingHere2.pl
line 1, near ""("Hello"
(Missing operator before Hello?)
String found where operator expected at C:\!!!!perl\whatWrongDoingHere2.pl
line1, near "n");""
syntax error at C:\!!!!perl\whatWrongDoingHere2.pl line 1, near ""("Hello World"
Execution of C:\!!!!perl\whatWrongDoingHere2.pl aborted due to compilation errors.
regards, gerry
----- Original Message -----
From:
To: "Steve Horn" ; ;
Sent: Thursday, August 30, 2007 6:27 AM
Subject: RE: What am I doing wrong here?
> Try
>
> print "Hello World.\n";
>
> -----Original Message-----
> From: activeperl-bounces@listserv.ActiveState.com
> [mailto:activeperl-bounces@listserv.ActiveState.com] On Behalf Of Steve
> Horn
> Sent: Thursday, August 30, 2007 6:11 AM
> To: perl-beginners@yahoogroups.com; activeperl@listserv.ActiveState.com
> Subject: What am I doing wrong here?
>
> On Windows Active State perl whenever I try to run the program "print
> ("Hello World.\n");"; I keep getting the error messages "Bareword found
> where operator expected at - line 1 near "print (Hello"" (missing
> operator before Hello?), String found where operator expected at - line
> 1 near ""print ("" (Missing semicolon on previous line?), and String
> found where operator expected at - line near "n");"". What am I doing
> wrong here and how do I fix this? TIA Steve
> --
> Steve Horn
> kcom1989@fastmail.fm
>
> --
> http://www.fastmail.fm - The professional email service
>
> _______________________________________________
> ActivePerl mailing list
> ActivePerl@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> _______________________________________________
> ActivePerl mailing list
> ActivePerl@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs