Error in command line

R

Rajendra Pai

Hi,

I have ActivePerl installed in a Windows XP Machine.

When I type the following line at the command prompt (this is just an
example):
perl -le 'print "PRIME" if (1 x shift) !~ /^(11+)\1+$/' 19
the response I get is:
Can't find string terminator "'" anywhere before EOF at -e line 1.

(I am getting similar error messages for 'perl -lane' type of commands
also. The example shown above is taken from a tutorial)

I am not able to figure out what is wrong. I have tried doing both web
and group searches in google. Please help me. I am a newbie and maybe
missing something very obvious.

Thanks in advance for the help.

Regards,
Rajendra
 
G

Gunnar Hjalmarsson

Rajendra said:
I have ActivePerl installed in a Windows XP Machine.

When I type the following line at the command prompt (this is just an
example):
perl -le 'print "PRIME" if (1 x shift) !~ /^(11+)\1+$/' 19
the response I get is:
Can't find string terminator "'" anywhere before EOF at -e line 1.

Use double-quotes on Windows.
 
M

Martin Kissner

Rajendra Pai wrote :
Hi,

I have ActivePerl installed in a Windows XP Machine.

When I type the following line at the command prompt (this is just an
example):
perl -le 'print "PRIME" if (1 x shift) !~ /^(11+)\1+$/' 19
the response I get is:
Can't find string terminator "'" anywhere before EOF at -e line 1.

On my computer the above line prints 'PRIME' and exits with no error.
However, I can not imagine what the trailing '19' is for.

Martin
 
B

Bill Smith

Rajendra Pai said:
Hi,

I have ActivePerl installed in a Windows XP Machine.

When I type the following line at the command prompt (this is just an
example):
perl -le 'print "PRIME" if (1 x shift) !~ /^(11+)\1+$/' 19


perl -le "print qq(PRIME) if (1 x shift) !~ /^(11+)\1+$/" 19

the response I get is:
Can't find string terminator "'" anywhere before EOF at -e line 1.

(I am getting similar error messages for 'perl -lane' type of commands
also. The example shown above is taken from a tutorial)

I am not able to figure out what is wrong. I have tried doing both web
and group searches in google. Please help me. I am a newbie and maybe
missing something very obvious.


Windows still requires DOS syntax in command lines.
You must use double quotes around parameters with
special characters. This prevents the use of
double quotes in perl command line commands.
In this case, single quotes around 'PRIME' would
work, but it is a good idea to use the q family
of operators within commands on the command line
because they will never be interpreted
by windows.

Bill
 
A

A. Sinan Unur

(e-mail address removed) (Rajendra Pai) wrote in @posting.google.com:
Hi,

I have ActivePerl installed in a Windows XP Machine.

When I type the following line at the command prompt (this is just an
example):
perl -le 'print "PRIME" if (1 x shift) !~ /^(11+)\1+$/' 19
the response I get is:
Can't find string terminator "'" anywhere before EOF at -e line 1.

While I find that the cmd.exe shell is fairly workable, its handling of
various quotation marks leaves a lot to be desired.

My brain has become accustomed to converting the above to:

perl -le "print q{PRIME} if (1 x shift) !~ /^(11+)\1+$/" 19

In this particular case, you cold have also done:

perl -le "print -PRIME if (1 x shift) !~ /^(11+)\1+$/" 19

if you don't mind the leading dash.

On the other hand, you are just using a one liner on the command line

Sinan
 
A

Anno Siegel

Martin Kissner said:
Rajendra Pai wrote :

On my computer the above line prints 'PRIME' and exits with no error.
However, I can not imagine what the trailing '19' is for.

It's an argument for shift() to pick up.

Anno
 

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,774
Messages
2,569,598
Members
45,156
Latest member
KetoBurnSupplement
Top