sub dev_ino_of_handle { my $handle = shift; join (" ", (stat $handle)); } sub send_maybe_both { my $text = shift; print STDOUT $text; unless (dev_ino_of_handle(\*STDOUT) eq dev_ino_of_handle(\*STDERR)) { print STDERR $text; } }