You might be interested in what Perl::Critic::Policy::InputOutput::ProhibitExplicitStdin and the corresponding part of PBP has to say about it. Also, you might want to consider checking via IO::Interactive to see if the terminal is actually interactive.
use warnings; use strict; use IO::Interactive 'is_interactive'; use Term::ReadLine; print "Hello, World!\n"; if ( is_interactive() ) { print "Press Enter to continue...\n"; Term::ReadLine->new("")->readline(""); } else { warn "Noninteractive, continuing...\n" }
This will prompt the user to press enter if connected to a terminal, but if the script is used in a non-interactive environment (simple example: perl script.pl | cat), it won't. See also other prompting alternatives.
In reply to Re: A readline + -e oddity: readline opens files even with -e --- need "readline STDIN" to read from console
by haukex
in thread A readline + -e oddity: readline opens files even with -e --- need "readline STDIN" to read from console
by cxw
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |