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!
In reply to No interactivity (prompt) after reading from pipe by svenXY
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |