use IO::Interactive qw(is_interactive); if ( is_interactive() ) { print "Running interactively\n"; }