unless (-t STDIN) { # check whether STDIN is a terminal exec (qw/xterm -e/,$0); # assuming that your perl file is executable }