in reply to piping commands to perl via standard input on the Win32 command line

Generally, when the STDOUT of a Win/DOS command misbehaves (from my UNIX-y expectations), especially where CMD.EXE's builtin commands are involved (e.g., echo), I have found that prefixing the command with CMD /c often does the trick.

That is, instead of:

echo "print qq(Hello.\n)" | perl

try this:

cmd /c echo "print qq(Hello.\n)" | perl

I use this primarily for capturing output from .BAT and .CMD files, but the builtin commands don't always work right either.

dmm

You can give a man a fish and feed him for a day ...
Or, you can
teach him to fish and feed him for a lifetime

Replies are listed 'Best First'.
Re: Re: piping commands to perl via standard input on the Win32 command line
by frag (Hermit) on Jan 11, 2002 at 21:40 UTC
    Actually, cmd /c echo "print qq(Hello.\n)" | perl doesn't work, either. (Although I didn't know about the /c switch before, so thanks for pointing that out.) As tye says, it's a fundamental problem with echo.

    -- Frag.
    --
    "Just remember what ol' Jack Burton does when the earth quakes, the poison arrows fall from the sky, and the pillars of Heaven shake. Yeah, Jack Burton just looks that big old storm right in the eye and says, "Give me your best shot. I can take it."