<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl

$num=1;

$stylesheet_url='&lt;LINK REL="STYLESHEET" HREF="http://www.akita-nct.ac.jp/yamamoto/stylesheet.css"&gt;';

$body='&lt;/BODY&gt;';
$google_analytics='
&lt;script src="http://www.google-analytics.com/urchin.js" type="text/javascript"&gt;
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
_uacct = "UA-2363198-1";
urchinTracker();
&lt;/script&gt;
&lt;/BODY&gt;
';

printf "================================================================\n";
printf " change css path and add google analytics script.\n";
printf "================================================================\n";


opendir(DIR,$ARGV[0]) or die "$ARGV[0] can not be opened. $!";
chdir($ARGV[0]);

while ($file=readdir(DIR)){
    if ($file=~ /.html$/ ){
	print "$num\t$file\n";
	open(IN,$file) or die "IN file can not be opened.";
	open(OUT,"&gt;changed.html") or die "OUT file can not be opened.";
	while(&lt;IN&gt;){
	    s/&lt;LINK\s+REL\s*=\s*"STYLESHEET"\s+HREF\s*=\s*.*&gt;$/$stylesheet_url/i;
	    s/&lt;\/BODY&gt;/$google_analytics/i;
	    print OUT;
	}
	close(IN);
	close(OUT);
	unlink($file);
	rename("changed.html",$file);
	$num ++;
    }
}

</pre></body></html>