Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Re: Multiple STDIN sources

by The Mad Hatter (Priest)
on Mar 10, 2004 at 00:29 UTC ( #335300=note: print w/replies, xml ) Need Help??

in reply to Re: Multiple STDIN sources
in thread Multiple STDIN sources

This is because it isn't reading it from a pipe in your test: it's reading it all from user input (as you typed in text followed by a control-D). If you do something like echo foo | ./stdin it does blow right past the prompt like the OP said.

Replies are listed 'Best First'.
Re: Multiple STDIN sources
by Abigail-II (Bishop) on Mar 10, 2004 at 00:40 UTC
    Oh, I see. In that case, just reopen STDIN, and read from the terminal:
    #!/usr/bin/perl -w use strict; $| = 1; my $stream; while (<>) { $stream .= $_; } open STDIN, "/dev/tty" or die; print "Do you want to process the stream? "; my $ans = <STDIN>; chomp $ans; print "Got '$ans'\n"; print "stream = $stream"; #... exit; __END__ $ echo foo | ./stdin Do you want to process the stream? yes Got 'yes' stream = foo $

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://335300]
[Corion]: But I really wonder - I can tell Chrome to go offline, but requesting pages over the network still succeeds. But if I manually click the "offline" checkbox, that's different :-/
[LanX]: Corion can you tell WMC to check the sub version number ?
LanX has to run

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2017-12-12 20:30 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (336 votes). Check out past polls.