svenXY has asked for the wisdom of the Perl Monks concerning the following question:
However, running it looks like this:#!/usr/bin/perl -w use strict; use Getopt::Std; my $what; $| = 1; my @hosts; my %opts; while (<STDIN>) { chomp; push(@hosts, $_); } getopts(':dw', \%opts); $what .= ' bla' if $opts{'d'}; $what .= ' blabla' if $opts{'w'}; print "OK? [Y|n]>\n"; my $yesno = <STDIN>; chomp $yesno; exit 1 if $yesno =~ /^[nN]$/; print "Did not stop, sorry!\n";
and does not stop to ask for input. I already tried different stuff and also supersearched, but to no avail.$ echo -e "aaa\nbbb\nccc\n" | script.pl -d OK? [Y|n]> Use of uninitialized value in scalar chomp at script.pl line 23, <STDI +N> line 4. Use of uninitialized value in pattern match (m//) at script.pl line 24 +, <STDIN> line 4. Did not stop, sorry!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: No interactivity (prompt) after reading from pipe
by Perl Mouse (Chaplain) on Nov 18, 2005 at 14:52 UTC | |
Re: No interactivity (prompt) after reading from pipe
by fizbin (Chaplain) on Nov 18, 2005 at 15:08 UTC | |
Re: No interactivity (prompt) after reading from pipe
by larryk (Friar) on Nov 18, 2005 at 14:32 UTC | |
by svenXY (Deacon) on Nov 18, 2005 at 14:41 UTC | |
by ptum (Priest) on Nov 18, 2005 at 14:48 UTC | |
Re: No interactivity (prompt) after reading from pipe
by ptum (Priest) on Nov 18, 2005 at 14:41 UTC | |
Re: No interactivity (prompt) after reading from pipe
by Aristotle (Chancellor) on Nov 18, 2005 at 14:50 UTC | |
Re: No interactivity (prompt) after reading from pipe
by svenXY (Deacon) on Nov 18, 2005 at 15:03 UTC |