in reply to WinNT Opendir with CGI

If CGI.pm calls binmode on STDIN on your platform (and I will suspect that it does), Perl won't internally translate the \r\n sequence into \n. That's the point of binmode.

In that case, chomp will remove the \n, but there will still be a trailing \r at the end of the filename.

Your error message ought to print "Cannot open $directory" and then the contents of $!. Since you're only getting $!, if you've reported the entire error message, it indicates that Perl printed the first part of the error, hit the \r, moved back to the first column, and printed the second half:

my ($one, $two) = qw( one two ); print "$one\r$two\n";
The simple fix is to strip out any carriage returns with a transliteration: $directory =~ tr/\r//d;

As a side note, I usually debug variables by printing them like print "Directory: ($directory)\n";. That helps make whitespace apparent.

Replies are listed 'Best First'.
Re: Re: WinNT Opendir with CGI
by strredwolf (Chaplain) on Feb 04, 2001 at 11:00 UTC
    You may want to try this instead of chomp:

    $var=~tr/\n\r//d; $var=~s/^\s+//;

    --
    $Stalag99{"URL"}="http://stalag99.keenspace.com";