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

Re: Multiple STDIN sources

by Abigail-II (Bishop)
on Mar 10, 2004 at 00:40 UTC ( [id://335302]=note: print w/replies, xml ) Need Help??


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

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 $
Abigail

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://335302]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 04:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found