|
From: Jonathan S. <gel...@ge...> - 2001-11-16 21:43:08
|
On Fri, 16 Nov 2001, Dave Cross wrote:
> On Fri, Nov 16, 2001 at 02:09:39PM -0500, Joseph F. Ryan (rya...@os...) wrote:
> > I was trudging through search.pl today, when I noticed that we weren't
> > using File::Find
>
<snip>
> Feel free to implement your change, but please use the $emulate_matts_code
> flag that we discussed a couple of days ago. When that flag is true then
> we must emulate Matt's code _exactly_.
>
This is one that I prepared earlier - and which I believe is being used by
the chemistry department of some university :
#!/usr/bin/perl -w
use strict;
use CGI qw(:standard);
use File::Find;
my $basedir = '/usr/local/apache/htdocs';
my $baseurl = 'http://localhost';
my $title = "Foo Foo Search";
my $title_url = 'http://localhost/';
my $search_url = 'http://localhost/search.html';
my $search = param('search');
my @pages;
find(\&getfiles,$basedir);
print header,start_html($title);
print "<UL>\n";
foreach (@pages)
{
print li,a({-href => $_->[0]}, $_->[1]),br,
"Size: $_->[2]",br,
"Last Modified : $_->[3]\n";
}
print "</UL>\n",end_html;
sub getfiles {
if ( /\.html?$/ && -T )
{
open(THIS,$_) || return;
my $text = do { local $/; <THIS> };
close(THIS);
if ( defined $search and $text =~ /$search/is )
{
my ($title) = $text =~ m#<title>(.*)</title>#is ;
$title ||= $_;
my $path = $File::Find::name;
$path =~ s/$basedir/$baseurl/;
push @pages,[$path,$title,-s, scalar localtime((stat)[9]) ];
}
}
}
No this isn't Matt compliant but it could be a start.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
|