
This page is Japanese only.
'98/4/2からカウントして
回アクセスされています
スクリプトとそれを説明するweb用のマニュアルを別々に管理するのが
大変になってきたので、「文芸的プログラミング」をすることにしました。
Web上での「文芸的プログラミング」というのは、スタンフォード大学の
Donald Knuthが提唱している、プログラムの作成とその文書化を同時に行う
手法を増井さんがWeb文書に適用したプログラミング方法です。
増井さんのスクリプトはPerl4対応なので、Perl5対応の物を作ってみました。
Perl5.6であれば正規表現だけで、特定のタグに囲まれたテキストを抽出できる
はずなんですが、まだやりかたがわからないので、<pre></pre>
で囲まれた文章を抽出するのにHTML::TokeParserを使っています。
#
# magick.pl
# Image::Magickを使ってリージョンファイルを作成する
# written by file-glob 991026
use Image::Magick;
use strict;
my ($file,$out,$image,$x,$w,$h,$t,$c,$data);
$file = shift;
$file =~ m/([^.]+)\..+/;
$out = $1 . ".rgn";
$data = "32,1,nCount,nRgnSize,0,0,";
$image = Image::Magick->new;
$x = $image->Read($file);
die "$x" if "$x";
($w,$h,$t) = $image->Get('columns','rows','pixel[0,0]');
$data .= sprintf("%d,%d,",$w,$h);
$c = 0;
for my $i (0..$h-1){
my ($in,$out);
$in = $out = 0;
for my $j (0..$w-1){
if (!$in && ($image->Get("pixel[$j,$i]") ne $t)){
$in = $j;
}elsif($in && (($image->Get("pixel[$j,$i]") eq $t)|| ($j == $w-1))){
$out = $j;
$data .= sprintf("%d,%d,%d,%d,",$in,$i,$out,$i+1);
$in = $out = 0;
$c++;
}
}
}
for ($data){
s/nCount/$c/e;
s/nRgnSize/$c*16/e;
}
open (OUT,">$out");
binmode OUT;
print OUT pack("L*",split(',',$data));
C:\>set http_proxy=proxy.hoge.co.jp:8080 <-- proxyを使っている場合、環境変数を設定する C:\>ppm.pl PPM interactive shell (1.0.0) - type 'help' for available commands. PPM> install Tk … PPM> exit C:\>
use Win32; my $text = "Perl ".$]. "\nBuild " . Win32::BuildNumber; Win32::MsgBox($text,0|MB_ICONQUESTION);このスクリプトを実行するとPerlのバージョンとビルド番号を書いたダイアログボックス を表示します。
use Win32::Shortcut;
$sc = new Win32::Shortcut();
$sc->Set("c:\\perl\\bin\\perl.exe", # Perlの場所
"info.pl", # shortcut 先のスクリプト
"e:\\sample", # スクリプトのある場所
"Prints out the version of Perl", # ショートカットの説明
SW_SHOWMAXIMIZES, # 起動したときのウィンドウの状態
hex('0x0337'), # ショートカットキーの設定 Ctr+Shift+7
"c:\\perl\\bin\\perl.exe", # Perlのアイコンを使う
0); # 真珠のアイコン
$sc->Save("c:\\winnt\\profiles\\file-glob\\デスクトップ\\perl.lnk");
# ショートカットを保存する場所
というスクリプトを実行することでWinNTのデスクトップ上にinfo.plのショートカット
を作ることができます。いかがなもんでしょう。
use Win32::OLE;
my $m = Win32::OLE->new('SPIRIT.SpiritCtrl.1');
die Win32::OLE->LastError unless $m;
これは動いたからなんとかなるんじゃないかな。