I ran across this in the Perl cook book .
Every program starts out with three global filehandles already opened: STDIN, STDOUT, and STDERR. STDIN (standard input) is the default source of input, STDOUT (standard output) is the default destination for output, and STDERR (standard error) is the default place to send warnings and errors. For interactive programs, STDIN is the keyboard, STDOUT and STDERR are the screen:
while (<STDIN>) { # reads from STDIN
unless (/\d/) {
warn "No digit found.\n"; # writes to STDERR
}
print "Read: ", $_; # writes to STDOUT
}
END { close(STDOUT) or die "couldn't close STDOUT: $!"
+ }