use strict; use warnings; use IO::Interactive qw(is_interactive); if (is_interactive){ print "interactive\n"; } else { print "piped\n"; }