#!/usr/bin/perl my $wwwdir = "/home/public/0"; my $menufile = "$wwwdir/.menu"; my @htmlfiles = `find $wwwdir -iname '*.html'`; my @menu; my $start = "## menu start ##"; my $end = "## menu end ##"; open (MENU, "$menufile") or die ("cant read $menufile $!"); @menu = (); close (MENU) or die ("cant close $menufile $!"); for $file (@htmlfiles) { chomp ($file); my $didit = 0; open (FILE, "$file") or die ("cant reead $file $!"); my @contents = (); close (FILE) or die ("cant close $file $!"); if ((grep /$start/,@contents) and (grep /$end/,@contents)) { open (TARGET, ">$file.tmp") or die ("cant write $file.tmp $!"); foreach (@contents) { if (/$start/ .. /$end/) { print TARGET ("@menu") unless ($didit == 1); $didit = 1; } else { print TARGET; } } close (TARGET) or die ("cant close $file.tmp $!"); rename ("$file.tmp", "$file") or die ("cant rename $file.tmp to $file $!"); } }