Bennett Haselton wrote:
> If you run this script on Windows:
>
> use CGI;
> print "hi\n";
>
> and redirect the output to output.txt and open output.txt in Notepad, you
> can see that the output became UNIX-style as a result of the "use CGI;"
> directive -- the newline was output as a UNIX newline (0x0a) instead of a
> Windows newline (0x0d0a). Without the "use CGI;" line, newlines get output
> normally.
>
> However, if you add the lines to the script:
> open(FILE, ">file.txt");
> print FILE "hi\n";
> close(FILE);
>
> then a proper Windows-style newline gets written to file.txt; apparently
> it's only redirected standard output that becomes UNIX-style.
>
> I emailed the author about it. I'll just workaround it when redirecting
> output, unless anyone can see something I'm obviously doing wrong.
That's because he does a binmode on STDIN, STDOUT and STDERR.
The reason for that is to handle file uploads and things like
that so the data isn't modified by adding/subtracting \r's
(like they do on these tinker toy systems).
You could get around it by modifying this line:
$needs_binmode = $OS =~ /^(WINDOWS|VMS|OS2)/;
in CGI.pm. I guess he should restrict it to uploads (that seems
possible) and downloads (but how does he know there is going to
be a download unless maybe he adds a method for it?) or just leave
it to the caller to set binmode (with mass warnings in the docs so
you don't forget). Most webservers/browsers can get by without the
\r's anyway.
--
,-/- __ _ _ $Bill Luebkert ICQ=14439852
(_/ / ) // // DBE Collectibles http://www.todbe.com/
/ ) /--< o // // Mailto:[EMAIL PROTECTED] http://dbecoll.webjump.com/
-/-' /___/_<_</_</_ http://www.freeyellow.com/members/dbecoll/
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users