On Sun, 27 Oct 2002, Ruslan U. Zakirov wrote:

> I'm writing handler which generate some html from files in requested
> dir if requested file does not exist.
> I have a problem with getting file list of the directory.
> I've tried to use IO::Dir, like this
>    my @htmls;
>    my $dh = new IO::Dir ($req_dir);
>    if (defined $dh)
>    {
>      while (defined($_ = $dh->read))
>      {
>        if(m/(\w*?\.html)/)
>        {
>          unshift(@htmls,$_);
>        }
>      }
>    }
> This code successfully create array, but at the same time apache prints
> something to user. And I have an abbracadabra in browser.
> May be I've missed some better way of getting file names?

As a latter message indicated, there's a number of ways of
getting a file listing - another possibility is

my $dir = '/usr/local/apache/htdocs';
opendir(DIR, $dir) or die "Cannot opendir $dir: $!";
my @htmls = grep { /\.html?$/ } readdir DIR;
closedir DIR;

But this doesn't seem to be the problem ... What's printed in the
browser? Is there anything in the error logs? Is the name of the
directory to be read input from the user (if so, are you running
under taint mode?), and are the permissions appropriate?

-- 
best regards,
randy kobes

Reply via email to