use BerkeleyDB; my $DB = new BerkeleyDB::Hash -Filename=>"/home/hogehoge/redirect.db" ; my $page = $ENV{'QUERY_STRING'}; my $newpage = ""; print "Status: 301 Moved Permanently\n"; if ( $page eq "" ) { print "Location: http://hgotoh.jp/wiki/\n\n"; } else { $page =~ s/page=(.+[^&]).*/$1/; if ( $DB->db_get($page, $newpage) == 0) { print "Location: http://hgotoh.jp/wiki/doku.php$newpage\n\n"; } else { print "Location: http://hgotoh.jp/wiki/olddoclist.html\n\n"; } } undef $DB;