Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

how to run commandline perl on windows

by aodukoya (Initiate)
on Mar 10, 2006 at 09:28 UTC ( #535643=perlquestion: print w/replies, xml ) Need Help??
aodukoya has asked for the wisdom of the Perl Monks concerning the following question:

Thanks that worked perfectly

Janitor note:- Original content follows:

I have a file sem.log on a Windows box and I have already installed perl, but when I try to run the following which is perfectly valid on Unix, on the window dos prompt I get an error...
perl -ane '$total += $F[9]; END {print $total}' sem.log
I get the following error:
Can't find string terminator "'" anywhere before EOF at -e line 1.
Is there a valid way of running commandline perl on windows without having to create a file.

Content restored by Arunbear, using RSS feed.

Replies are listed 'Best First'.
Re: how to run commandline perl on windows
by PodMaster (Abbot) on Mar 10, 2006 at 09:36 UTC
    'perldoc perlrun'
    Command-interpreters on non-Unix systems have rather different ideas on quoting than Unix shells. You'll need to learn the special characters in your command-interpreter ("*", "\" and """ are common) and how to protect whitespace and these characters to run one-liners (see -e below).

    On some systems, you may have to change single-quotes to double ones, which you must *not* do on Unix or Plan 9 systems. You might also have to change a single % to a %%.

    For example:

    # Unix perl -e 'print "Hello world\n"' # MS-DOS, etc. perl -e "print \"Hello world\n\"" # Macintosh print "Hello world\n" (then Run "Myscript" or Shift-Command-R) # VMS perl -e "print ""Hello world\n"""
    The problem is that none of this is reliable...
    So you'd have to try something like
    perl -ane " $total += $F[9]; END {print $total} " sem.log
    Writeup formatting tips

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: how to run commandline perl on windows
by lamp (Chaplain) on Mar 10, 2006 at 09:41 UTC

    Use " (double quotes) instead of single quotes.

    perl -ane "$total += $F9; END {print $total}" sem.log

    Update: Ah, PodMaster has already posted the answer.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://535643]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2017-05-25 10:14 GMT
Find Nodes?
    Voting Booth?