#!/usr/bin/perl use Getopt::Std; getopt(''); print "\nTest Mode -- no changes made!\n\n" if ($opt_t); $src = "/home/fred/"; $tgt = "/var/www"; $now = time; # get a GMT string @Mth = qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/; @gt = gmtime; $gmt = sprintf "%02d-%s-%04d %02d:%02d",$gt[3],$Mth[$gt[4]],$gt[5]+1900,$gt[2],$gt[1]; # supported file types %ftypes = ( pub => html, 'pub/stories' => html, 'pub/pictures' => 'gif|jpg', 'pub/trivia' => html ); foreach $dir (keys %ftypes){ chdir "$src/$dir"; if (open (HOLD,".hold") ){ while( ){ chomp; $hold{$_}++ } } @ftype = split (/\|/,$ftypes{$dir}); foreach $ft ( @ftype){ # print "$dir $ft\n"; @pub_html = glob("*$ft"); foreach $x (@pub_html){ next if ( $x =~ /^temp\./ ); next if ( $hold{$x}); next if ( (-M "$src/$dir/$x") >= (-M "$tgt/$dir/$x") && (-f "$tgt/$dir/$x") ); print "$src/$dir/$x -> $tgt/$dir/$x\n"; next if ($opt_t); open (SRC,"$src/$dir/$x") || die "Cannot open $src/$dir/$x\n"; open (TGT,">$tgt/$dir/$x") || die "Cannot write to $tgt/$dir/$x\n"; while (){ s#"(\.\./)+#"/#; s#"index.shtml"#"/"#g; s#"/index.shtml"#"/"#g; if (/^\s*Last Updated: .* GMT
$/){ $_ = "\tLast Updated: $gmt GMT
\n"; } print TGT $_; } close(TGT) || die "Cannot close $tgt/$dir/$x\n"; utime $now,$now,"$src/$dir/$x","$tgt/$dir/$x"; chmod 0644,"$tgt/$dir/$x","$src/$dir/$x"; } } }