Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > "Bareword found where operator expected" in for loop.

Reply
Thread Tools

"Bareword found where operator expected" in for loop.

 
 
aaron.mosiah.curtis@gmail.com
Guest
Posts: n/a
 
      05-10-2006
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.

 
Reply With Quote
 
 
 
 
Ben Morrow
Guest
Posts: n/a
 
      05-10-2006

Quoth :
> 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

--
The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching.
Assyrian stone tablet, c.2800 BC
 
Reply With Quote
 
 
 
 
A. Sinan Unur
Guest
Posts: n/a
 
      05-10-2006
wrote in news:1147289408.665621.97710
@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/html...html#perlavail

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

Sinan
 
Reply With Quote
 
DJ Stunks
Guest
Posts: n/a
 
      05-10-2006

Jim Gibson wrote:
> In article <. com>,
> <> wrote:
>
> > 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

>
> 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

 
Reply With Quote
 
Michele Dondi
Guest
Posts: n/a
 
      05-10-2006
On 10 May 2006 12:30:08 -0700, wrote:

>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
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Module not found in script that was found incommand-line interpreter. Possible Path issue? Trent Mick Python 0 04-03-2008 05:54 PM
One File Found, the other Not Found ?!?!?! mcampo84@gmail.com Java 3 08-07-2006 09:49 PM
Re: Found.0001.CHK to Found.014.CHK folders pcbutts1 Computer Support 2 07-24-2005 01:13 PM
Re: Found.0001.CHK to Found.014.CHK folders pcbutts1 Computer Support 0 07-24-2005 12:08 PM
Namespace not found in aspx but IS found in code behind William Parker ASP .Net 1 06-27-2004 06:13 AM



Advertisments