ibjdt
Programmer
- Nov 25, 2002
- 63
i want to allow users to search documents file names via cgi script.
i found some code and modified per below.
the script hasn't worked and doesn't appear to actually be accessing the directory.
i added a counter and several other print statements to track progress. it only goes through one loop (output shown below script). in fact, in its current state i ask the script to print the filename to screen - i get a blank line.
how can i determine if it's accessing the dir??
please help.
thanks.
i found some code and modified per below.
the script hasn't worked and doesn't appear to actually be accessing the directory.
i added a counter and several other print statements to track progress. it only goes through one loop (output shown below script). in fact, in its current state i ask the script to print the filename to screen - i get a blank line.
how can i determine if it's accessing the dir??
please help.
thanks.
Code:
use File::Find;
my $q = new CGI;
print $q->header;
my $query = $q->param("query");
print "\n<p>For the query $query, these results were found:</p>\n<ol>\n";
undef $/;
find(&findit, "/data");
sub findit
{
print "$File::Find::name<br><br>";
return if($_ =~ /^\./);
stat $File::Find::name;
return if -d;
# return unless -r;
$count++;
print "$count<br><br>";
# return unless (/$query/i);
print "$File::Find::dir";
print "<li>hello<a href=\"$File::Find::name\">$File::Find::name</a></li>\n";
print "done1";
}
print "</ol>\n";
print "done";
exit;
Code:
OUTPUT
===========
For the query t, these results were found:
***filename should be here***
1
hello done1
done