Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Piped input read by Windows Vista but not by Windows XP

by roho (Monsignor)
on Nov 01, 2010 at 19:52 UTC ( #868871=perlquestion: print w/ replies, xml ) Need Help??
roho has asked for the wisdom of the Perl Monks concerning the following question:

I have AS Perl 5.8.9 (build 827) on Windows Vista and Windows XP. Piped input is read by the Perl program on Vista but is not read by the same Perl program on XP, even though Perl programs can be run implicitly on both Vista and XP by just entering the program name on the command line.

Following is the command line I am using and the Perl program I am piping input to. This is a simplified example to show the difference between how Vista and XP handle piped input. I am grepping all lines of a file (the test program in this case, but it could be any file) with the '-n' option to precede each line with a line number and colon. The output of grep is piped to the Perl program where the colon following the line number is removed and the line is printed.

Note: I found that if I use '... | perl test.pl' instead of '... | test.pl' on XP it will read the piped input, but I do not believe I should have to do that to make it work. Does anyone have any ideas why piped input is not read on XP? Thanks.

grep -n "^" test.pl | test.pl #!/usr/bin/perl # Perl program test.pl use strict; use warnings; while ( <> ) { chomp; s/:/ /; print "$_\n"; }

"Its not how hard you work, its how much you get done."

Comment on Piped input read by Windows Vista but not by Windows XP
Download Code
Re: Piped input read by Windows Vista but not by Windows XP
by kcott (Abbot) on Nov 01, 2010 at 23:29 UTC

    While I can't give you an answer as to why, I can confirm this behaviour. I first tried your code on cygwin: pipe worked fine. Then tried with XP (using same code and running from the same directory): got the same as you. Furthermore, taking the input from stdin rather than pipe worked fine.

    Here's my tests:

    ken@Miranda ~/c/_/tmp $ cat > xp_pipe_prob.pl #!perl use strict; use warnings; while (<>) { chomp; s/:/ /; print "$_\n"; } ken@Miranda ~/c/_/tmp $ echo 'fred:derf' fred:derf ken@Miranda ~/c/_/tmp $ chmod +x xp_pipe_prob.pl ken@Miranda ~/c/_/tmp $ echo 'fred:derf' | xp_pipe_prob.pl fred derf ken@Miranda ~/c/_/tmp $ Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\_\tmp>echo 'fred:derf' 'fred:derf' C:\_\tmp>echo 'fred:derf' | xp_pipe_prob.pl C:\_\tmp>echo 'fred:derf' | perl xp_pipe_prob.pl 'fred derf' C:\_\tmp>xp_pipe_prob.pl fred:derf fred derf C:\_\tmp>

    -- Ken

Re: Piped input read by Windows Vista but not by Windows XP
by Anonymous Monk on Nov 02, 2010 at 00:12 UTC
      Thanks for the explanation. It makes sense now. Too bad M$ never got around to fixing this in XP.

      "Its not how hard you work, its how much you get done."

        It has been fixed in most cases for a long time. See Re: Out of date over <> and 5.10 (redir) for more about it. Still, nobody has been able to demonstrate what causes only some instances to exhibit this problem.

        - tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://868871]
Approved by lostjimmy
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2014-10-02 01:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (41 votes), past polls