use IO::Interactive qw( is_interactive ); # and later... if (is_interactive()) { print $PROMPT; }