#/usr/bin/perl -w use strict; my (%file_index, %words_index); opendir( DIR, ".") or die "Could not read from current directory - $!\n"; my @files = grep { -f and /\.html$/} readdir DIR; closedir DIR; local $/; my $default_description = "No description"; my $default_title = "No title"; for my $file (@files) { open(FILE, "$file") or die "Can't open file $file - $!\n"; my $whole_file = ; close(FILE); my $title; if ($whole_file =~ /\s*(.*)\s*<\/TITLE>/is) { ($title=$1) =~ s/\s+/ /g; $title =~ s/ *$//; $title =~ s/ +/ /g; } $file_index{$file}{'TITLE'} = defined $title ? $title : $default_title; ## Similar stuff (using META tags perhaps?) goes here $file_index{$file}{'DESCRIPTION'} = $default_description; for (split(/\W+/, join(" ", split(/<[^>]*>/, $whole_file)))) { $words_index{$_}{$file}++; } print "$file - ($file_index{$file}{'TITLE'}) - " . "$file_index{$file}{'DESCRIPTION'}\n"; }