"Bareword found where operator expected" in for loop.

  • Thread starter aaron.mosiah.curtis
  • Start date
A

aaron.mosiah.curtis

I downloaded some perl scripts that I can't get to compile. I think the
scripts were written for perl4 and the syntax changes in perl5 are
throwing errors about a for loop that is repeated with different
variables throughout the script.

The entire script (not very large) is visible at the following url:
http://www.mockus.us/oss/apache/script

Here is an example of the for loop:

#process mail folders
#cat together cvs messages
for i in $(ls mail/cvs*.gz | sort);do gunzip -c $i; done > cvsmail
for i in $(ls mail/cvs*[0-9] | sort);do cat $i; done >> cvsmail

When I try to complie the script, I get the following errors:

Bareword found where operator expected at script.pl line 7, near "$(ls"
(Missing operator before ls?)
Use of /c modifier is meaningless without /g at script.pl line 12.
Bareword found where operator expected at script.pl line 12, near "for
i in $(ls mail/cvs"
(Might be a runaway multi-line // string starting on line 7)
(Do you need to predeclare for?)
Unquoted string "vs" may clash with future reserved word at script.pl
line 12.
syntax error at script.pl line 7, near "for i in "
sort is now a reserved word at script.pl line 12.

As best as I can tell, the compiler is not recognizing ls as an
operator and is treating everything in the parenthesis as a string. The
'/' in the directory listing mail/cvs*.gz appears to be recognized as a
modifier, which is messing up the following for loop.

This looks like something I saw in a perltrap document, but I'm not
experienced enough with perl to adjust the code to the requirements of
perl5. I'll keep going over the documentation for perl5, but in the
mean time, if anyone can help me fix this error, I'd appreciate it.

Alternatively, if anyone knows how I can obtain and install perl4 on my
windows box, that might fix the problem as well.
 
B

Ben Morrow

Quoth (e-mail address removed):
I downloaded some perl scripts that I can't get to compile. I think the
scripts were written for perl4 and the syntax changes in perl5 are
throwing errors about a for loop that is repeated with different
variables throughout the script.

The entire script (not very large) is visible at the following url:
http://www.mockus.us/oss/apache/script

Here is an example of the for loop:

#process mail folders
#cat together cvs messages
for i in $(ls mail/cvs*.gz | sort);do gunzip -c $i; done > cvsmail
for i in $(ls mail/cvs*[0-9] | sort);do cat $i; done >> cvsmail

This is not a Perl script, it is a shell script.
Alternatively, if anyone knows how I can obtain and install perl4 on my
windows box, that might fix the problem as well.

A couple of shells, and a number of other tools you would need to make
that script work (ls, sort, gunzip and cat in the above are expected to
be separate programs) are available for win32 from unxutils.sf.net.
Alternatively, you may have more luck with Cygwin (google for it), as
the script probably makes many Unix-ish assumptions.

Ben
 
A

A. Sinan Unur

(e-mail address removed) wrote in @g10g2000cwb.googlegroups.com:
I downloaded some perl scripts that I can't get to compile. I think the
scripts were written for perl4
....

The entire script (not very large) is visible at the following url:
http://www.mockus.us/oss/apache/script

Ahem:

#!/bin/ksh
#obtain archives from apache site
perl geturl.perl

The fact that a shell script is invoking perl does not make the shell
script a Perl script.

....
Alternatively, if anyone knows how I can obtain and install perl4 on my
windows box, that might fix the problem as well.

http://www.pa.msu.edu/reference/htmlchek/awk-perl.html#perlavail

but I don't know why you would want it.

Sinan
 
D

DJ Stunks

Jim said:
Those are not Perl 4 scripts. Perl 4 is very compatible with the
current Perl 5 versions. Those look like shell scripts.

begin mocking him! (hey, he asked)

-jp
 
M

Michele Dondi

I downloaded some perl scripts that I can't get to compile. I think the
scripts were written for perl4 and the syntax changes in perl5 are
throwing errors about a for loop that is repeated with different [snip]
for i in $(ls mail/cvs*.gz | sort);do gunzip -c $i; done > cvsmail
for i in $(ls mail/cvs*[0-9] | sort);do cat $i; done >> cvsmail

No perl 4. No perl at all. Just shell. What did make you think it was
Perl?


Michele
 

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
474,262
Messages
2,571,059
Members
48,769
Latest member
Clifft

Latest Threads

Top