
#!/usr/bin/perl
use strict;
use warnings;
use Encode;
use CGI;
use URI;
use LWP::Simple;
use utf8;
my $q = new CGI;
my $url = $q->param('url') || "";
my $cont = $url ? (get($url) || "") : "";
my ($page_charset, $page_encoding) = ("UTF-8", "utf8");
if ($cont =~ /charset=(EUC-JP|Shift_JIS)/i) {
$page_charset = $1;
$page_encoding = "euc-jp" if $page_charset =~ /EUC-JP/i;
$page_encoding = "shiftjis" if $page_charset =~ /Shift_JIS/i;
}
print $q->header(-charset => $page_charset);
if ($cont eq "") {
print qq(<html><head><title>wrapper</title></head>
<body><form method="get" target="_blank">
<input type="input" name="url" size="80">
<input type="submit"></form></body></html>\n);
exit;
}
$cont =~ s{(<\s*head\s*>)}{$1<base href="$url">}i;
$cont = decode($page_encoding, $cont) if not utf8::is_utf8($cont);
# do something vvv
$cont =~ tr/ぁ-ん/ァ-ン/;
# do something ^^^
print encode($page_encoding, $cont);
![]() |
| 夜の六本木を歩く |