Help for this page

Select Code to Download


  1. or download this
    How do I find out if I'm running interactively or not?
    Good question. Sometimes -t STDIN and -t STDOUT can give clues, someti
    +mes not.
    
    ...
        } else {
            print "background\n";
        }
    
  2. or download this
        $on_a_tty = -t STDIN && -t STDOUT;
        sub prompt { print "yes? " if $on_a_tty }
        for ( prompt(); <STDIN>; prompt() ) {
            # do something
        }