Closed p5pRT closed 21 years ago
When using ActivePerl build 804 (based on v5.8.0) on a Windows machine\, perldoc is unusable. It outputs the information separated with \n rather than with \r\n\, causing output
with lines like these
The ActivePerl I used previously (based on 5.6.1\, IIRC) did not have this problem.
I have a workaround: starting a DJGPP sh.exe and then using\, for example\, perldoc -f sysopen | cat | more (with the cat in the middle doing LF-to-CRLF translation for me)\, but that's a bit ridiculous.
I believe the problem may stem from this sequence of events:
- perldoc creates a temporary file to write output data into (to pass this file to a pager). - it allocates this file with File::Temp::tempfile - File::Temp::tempfile calls _gettemp - _gettemp opens the file with sysopen() not with normal open() - It uses $OPENFLAGS or $OPENTEMPFLAGS for the sysopen flags - $OPENFLAGS is initialised with a binary or of bits including O_BINARY\, if found (lines 202ff. in File/Temp.pm) ($OPENTEMPFLAGS simply adds O_TEMPORARY if available) - Therefore\, the temporary files created with File::Temp::tempfile are always opened in binary mode if the system supports such a mode - So the \n stays \n - Problem.
(At first I was confused becausing I thought there might be a stray binmode() but didn't find one; I'm now convinced the evildoer was the O_BINARY flag.)
I'm not sure what a good solution is -- maybe add a flag to File::Temp::tempfile enabling the user to request a text-mode file\, and then passing that flag from withing perldoc? At any rate\, it's rather tortuous using perldoc like this now (and I think it's not an ActivePerl problem\, but rather perl _per se_\, which is why I'm perlbugging a report)\, and I usually read the text-mode version rather than the HTML docs\, which are undoubtedly fine (and most browsers can handle both \n and \r\n anyway -- but Windows's more.exe can't).
[Philip.Newton \<!--c--> \at\ \<!--a--> gmx.net - Thu Jan 2 21:24:27 2003]:
I'm not sure what a good solution is -- maybe add a flag to File::Temp::tempfile enabling the user to request a text-mode file\, and then passing that flag from withing perldoc? At any rate\, it's rather tortuous using perldoc like this now (and I think it's not an ActivePerl problem\, but rather perl _per se_\, which is why I'm perlbugging a report)\, and I usually read the text-mode version rather than the HTML docs\, which are undoubtedly fine (and most browsers can handle both \n and \r\n anyway -- but Windows's more.exe can't).
I can't reproduce this problem on Windows NT (though I can see the temp file created by perldoc _is_ getting created in binmode() as you say).
The 'more' on Windows NT certainly handles UNIX-style text files just fine. The only thing I know of that can't handle these files properly is 'notepad'. Perhaps you're on Windows 9x?
And there is no 'more.exe'\, only 'more.com' on Windows\, AFAIK. Where is your 'more.exe' from?
Sarathy gsar@ActiveState.com
On 03 Jan 2003 05:24:28 GMT\, Philip Newton wrote:
# New Ticket Created by Philip Newton # Please include the string: [perl #19682] # in the subject line of all future correspondence about this issue. # \<URL: http://rt.perl.org/rt2/Ticket/Display.html?id=19682 >
Not sure if the RT system forwards followups to p5p\, but I added a reply in RT to this report. Please visit above URL.
Sarathy gsar@ActiveState.com
On Fri\, 03 Jan 2003 10:18:11 -0800\, gsar@ActiveState.com (Gurusamy Sarathy) wrote:
On 03 Jan 2003 05:24:28 GMT\, Philip Newton wrote:
# New Ticket Created by Philip Newton # Please include the string: [perl #19682] # in the subject line of all future correspondence about this issue. # \<URL: http://rt.perl.org/rt2/Ticket/Display.html?id=19682 >
Not sure if the RT system forwards followups to p5p\, but I added a reply in RT to this report. Please visit above URL.
It appears not to\, but I believe the other way around will work\, so I'll comment here.
The 'more' on Windows NT certainly handles UNIX-style text files just fine. The only thing I know of that can't handle these files properly is 'notepad'. Perhaps you're on Windows 9x?
Indeed I am; sorry for not making that clear in the bug report (Win98SE\, to be more precise).
(Maybe it's also a difference between COMMAND.COM and CMD.EXE? Don't know. On the other hand\, creating a Unix-style file and then invoking 'more' on it also gives me a ladder-type display\, so it's likely a difference between NT's more.com and 9x's.)
And there is no 'more.exe'\, only 'more.com' on Windows\, AFAIK. Where is your 'more.exe' from?
Er\, you're right; it *is* 'more.com' (in C:\WINDOWS\COMMAND). I was ass-u-ming that it was an .exe but it isn't.
Let me re-phrase the last sentence as "most browsers can handle both \n and \r\n anyway -- but Windows 98's more.com can't".
Cheers\, Philip
Do I understand correctly that this is simply a documentation issue\, as in "do not try to use the Win98 more.com as your pager"?
On 23 Jan 2003 at 4:12\, via RT wrote:
Do I understand correctly that this is simply a documentation issue\, as in "do not try to use the Win98 more.com as your pager"?
*tries a few things out* Maybe. "type" can also not handle \n- terminated lines\, but when I "binmode STDOUT" and then output \n- terminated lines from Perl\, it displays correctly. (And DJGPP 'od' says that with binmode it sees '\n' and without it sees '\r\n'\, so the binmode does have an effect.) So I suppose the actual console output routines (or command.com\, or whoever is responsible) *can* handle \n as line terminator.
Still\, there isn't much choice under Win98. I don't think using WordPad as a pager (as ActiveState support suggested) is really the right solution. (And I don't even know whether it accepts input from STDIN anyway.) Hardly anyone\, I'll assume\, has DJGPP less or Vern Buerg's LIST or some other pager.
I think it would be much preferable to open the temporary file in text mode -- after all\, Perl documentation is (more or less by definition) text. That way\, we could accommodate Win98's brain-damaged more.com; after all\, in previous releases it worked all right (when perldoc opened its own temp file in the default -- text -- mode rather than relying on File::Temp\, which opens files in binary mode).
What do you suggest? Documenting that Win98's more.com does not work as a pager? What should Win98 users use then? (Note that "no pager" is not an option\, either\, since the Win9x console window does not have scrollback the way NT consoles do -- so you only see the last max. 50 lines. At least as far as I can see. And telling them to "redirect output into a text file and open that with your favourite editor" is not very user-friendly\, either\, IMO.)
Cheers\, Philip -- Philip Newton \Philip\.Newton@​gmx\.net
I have experienced the same problem with perldoc on both of my Win98
boxes since updating to 5.8.0. I found another user in the c.l.p.m
newsgroup whose perldoc works on his WinNT box\, but not his Win95 box.
This seems to support the idea that the problem is related to Win98's
more.com.
I guess I'll look into a different pager. I haven't found a silver- bullet for this anywhere.
--Rick rick_is@bigfoot.com
On 11 Feb 2003 at 6:29\, via RT wrote:
I guess I'll look into a different pager. I haven't found a silver- bullet for this anywhere.
I have\, thanks to Sean M. Burke\, who suggested installing Pod::Perldoc. That module comes with a replacement 'perldoc' script which Does The Right Thing on Windows.
It's pure Perl\, so just fetch it from CPAN. If you have a make utility (preferably Microsoft's nmake\, since that's what ActivePerl was built with)\, then the standard "perl Makefile.PL; make; make install" should work.
Otherwise copy Pod\Perldoc.pm to a directory under @INC and put perldoc into the Perl "bin" directory; it may need converting to a batch file by hand (with pl2bat) so that you can simply call it as "perldoc".
Cheers\, Philip -- Philip Newton \Philip\.Newton@​gmx\.net
Thanks again.
Since I have the default Activestate binary distribution\, it was even easier.
PPM>install Pod::Perldoc
When the install finished\, perldoc worked. (It even creates perldoc.bat).
--R Clary rick_is@bigfoot.com
Since Pod::Perldoc is in the core now\, we'll call this resolved.
@schwern - Status changed from 'new' to 'resolved'
Migrated from rt.perl.org#19682 (status was 'resolved')
Searchable as RT19682$