use CGI; binmode $_, ':crlf' for (\*STDOUT, \*STDERR, \*STDIN); print "foo\nbar\n";