use strict; use warnings; use IO::Prompt; while( prompt "next: " ) { print "You said '$_'\n"; } #### $ cat > test.txt Hello World ^D $ perl ./prompt.pl < test.txt You said: Hello You said: World $ cat test.txt | perl ./prompt.pl You said: Hello You said: World #### use strict; use warnings; use IO::Interactive qw(is_interactive); if (is_interactive){ print "interactive\n"; } else { print "piped\n"; } #### $ perl ./interactive.pl intereactive $ cat test.txt | perl ./interactive.pl piped $ perl ./interactive.pl < test.txt piped