#!/usr/bin/perl if (-t STDERR) { # connected to terminal? print STDERR "msg-to-stderr\n"; } print "msg-to-stdout\n";