#/usr/bin/perl -w use strict; my %words_index; my %file_index; opendir( DIR, "./"); @files = grep { -f and /\.html$/} readdir DIR; closedir DIR; undef $/; foreach my $file (@files) { my $default_description = "No description"; my $whole_file; open( FILE, $file) || die "Can't open file $file - $!\n"; $whole_file = ; $whole_file =~ /(.*)<\/html>/i; $file_index{ $file }{TITLE} = $1; $file_index{ $file }{DESCRIPTION} = $default_description; $whole_file =~ s/<[^>]*>//g; @words = split / /, $whole_file; foreach my $word (@words) { $words_index{ $word }{ $file } += 1; } print "$file - $file_index{ $file }{TITLE} - $file_index{ $file }{DESCRIPTION}\n"; close FILE; }