"Bareword found where operator expected" in for loop.

Discussion in 'Perl Misc' started by aaron.mosiah.curtis@gmail.com, May 10, 2006.

  1. Guest

    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.
     
    , May 10, 2006
    #1
    1. Advertising

  2. Ben Morrow Guest

    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
     
    Ben Morrow, May 10, 2006
    #2
    1. Advertising

  3. 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/htmlchek/awk-perl.html#perlavail

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

    Sinan
     
    A. Sinan Unur, May 10, 2006
    #3
  4. DJ Stunks Guest

    Jim Gibson wrote:
    > In article <>,
    > <> 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
     
    DJ Stunks, May 10, 2006
    #4
  5. 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,
     
    Michele Dondi, May 10, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VGltOjouLg==?=

    Loop the loop...

    =?Utf-8?B?VGltOjouLg==?=, Feb 16, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    1,386
    Karl Seguin
    Feb 16, 2005
  2. Steven

    while loop in a while loop

    Steven, Mar 24, 2005, in forum: Java
    Replies:
    5
    Views:
    2,243
    Tim Slattery
    Mar 30, 2005
  3. -
    Replies:
    12
    Views:
    698
    Remon van Vliet
    Jun 15, 2005
  4. Byte
    Replies:
    4
    Views:
    418
  5. Isaac Won
    Replies:
    9
    Views:
    391
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page