graff has asked for the wisdom of the Perl Monks concerning the following question:
When I step through that last example with "perl -de", it never enters the while loop -- the first attempt to read input with the diamond operator fails (or yields the equivalent of EOF), and execution goes directly to the last line.bash$ ls junk test.junk bash$ ls | sed 's/\./-.-/' # piping between GNU utils works junk test-.-junk bash$ ls > junk bash$ perl -pe 's/\./-.-/' junk # perl reading from a file works junk test-.-junk bash$ perl -pe 's/\./-.-/' < junk # redirecting stdin from file works junk test-.-junk bash$ ls | perl -pe 's/\./-.-/' # using a pipeline # nothing comes out # trying the pipe again, more carefully this time: bash$ ls | perl -e 'while (<>) { > s/\./-.-/; > print; > } > print "all done\n";' all done
Any clues or hints about what's going wrong here? What am I missing?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Read from a pipe with WinXP/AS 5.8.2?
by BrowserUk (Patriarch) on Jan 07, 2004 at 04:56 UTC | |
by graff (Chancellor) on Jan 07, 2004 at 05:16 UTC | |
|
Re: Read from a pipe with WinXP/AS 5.8.2?
by ysth (Canon) on Jan 07, 2004 at 04:53 UTC |