変換モジュール作成
(2004.08.05)
自分のホームページでおきまりのフレーズを間違いなく入れるために、文字列を変換する簡単なモジュールを作成しました。
使用例
Windows → Wi(うへぇ)ws
あ。変換前の文字列まで変換されてるから、うまく示せません。
ではもう一度。
使用例(画像版)

→ Windows
設定ファイルppconfig.txtに変換前と変換後を入れておきます。
# for modules PpTransrate
PpTransrate0:
Wi(うへぇ)ws
モジュールはこんな感じ。
# $VER: module PpTransrate for ppmod. 1.0, 2004/08/04
package PpTransrate;
local @before;
local @after;
sub init
{
my($child) = @_;
main::putmessage('verbose', "module load.");
main::putmessage('verbose', "config = '$child->{pathname}'");
main::putmessage('verbose', "**********");
my $root;
for ($root = $child; $root->{parent}; $root = $root->{parent})
{
}
main::putmessage('verbose', "transrate word");
@before = ();
@after = ();
my $item;
foreach $item (sort(keys(%{$root->{config}})))
{
if ($item =~ /^PpTransrate/)
{
my $config = $root->{config}->{$item};
my @line = split(' ', $config);
push(@before, $line[0]);
push(@after, $line[1]);
main::putmessage('verbose', "transrate '$line[0]' to '$line[1]'");
}
}
main::putmessage('verbose', "**********");
push(@main::filters, \&filter_transrate);
}
sub filter_transrate
{
my($junk, @outhtml) = @_;
my $item;
for ($item = 0; $item < @before; $item++)
{
my $linebuff;
foreach $linebuff (@outhtml)
{
$linebuff =~ s/$before[$item]/$after[$item]/g;
}
}
return @outhtml;
}
1;