in reply to How to end a process started with open "cmd |" before it has output
just replace the above $response = <> with your system call or whatever..my $timeout = 5; eval { #traps fatal alarm.. local $SIG{ALRM} = sub { die "alarm\n" }; #\n required alarm $timeout; print "Do you suck (Y/N)?"; $answer = <>; alarm 0; }; + if (!($@)) { #looks like they typed something Y?... if ($answer =~ /[Nn]/) { # guess they dont suck $suck = 0; } else { #suck = 1; } } else { $suck = 1; print "You didn't type anything you suck..\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How to end a process started with open "cmd |" before it has output
by Crackers2 (Parson) on May 07, 2004 at 03:01 UTC |