<?xml version='1.0' encoding='utf-8'?>
<pod xmlns="http://axkit.org/ns/2000/pod2xml">
<head>
	<title>perlfaq3 - Programming Tools ($Revision: 1.38 $, $Date: 1999/05/23 16:08:30 $)</title>
</head>
<sect1>
<title>perlfaq3 - Programming Tools ($Revision: 1.38 $, $Date: 1999/05/23 16:08:30 $)</title>
<para>
perlfaq3 - プログラミングツール ($Revision: 1.38 $, $Date: 1999/05/23 16:08:30 $)
</para>
</sect1>
<sect1>
<title>DESCRIPTION</title>
<para>
FAQのこのセクションでは、プログラマーツールやプログラミングサポートに
関する質問に回答しています。
</para>
<sect2>
<title>How do I do (anything)?</title>
<para>
(○○をするにはどうすればいいの?)
</para>
<para>
CPAN(<link xref='perlfaq2'>perlfaq2</link>を参照して下さい)はもう見ましたか? 
あなたの問題を解決してくれるような
モジュールを誰かがすでに作っているのを見つけられるかもしれません。
適切なマニュアルページは見ましたか?
簡単なインデックスを挙げておきます:
</para>
<verbatim><![CDATA[
基礎		perldata, perlvar, perlsyn, perlop, perlsub
実行		perlrun, perldebug
関数		perlfunc
オブジェクト	perlref, perlmod, perlobj, perltie
データ構造	perlref, perllol, perldsc
モジュール	perlmod, perlmodlib, perlsub
正規表現	perlre, perlfunc, perlop, perllocale
perl5への移行	perltrap, perl
Cとのリンク	perlxstut, perlxs, perlcall, perlguts, perlembed
その他  	http://www.perl.com/CPAN/doc/FMTEYEWTK/index.html
		(man-page ではありませんが有用です)
]]></verbatim>
<para>
A crude table of contents for the Perl man page set is found in <link xref='perltoc'>perltoc</link>.
</para>
<para>
無加工の Perl のマニュアルページセットの目次の一覧が<link xref='perltoc'>perltoc</link>にあります。
</para>
</sect2>
<sect2>
<title>How can I use Perl interactively?</title>
<para>
(どうすれば対話的にPerlを使えますか?)
</para>
<para>
典型的なやり方は、perldebug(1)マニュアルページにあるような Perl
デバッガを以下の例のように“空の”プログラムに対して使うことです:
</para>
<verbatim><![CDATA[
perl -de 42
]]></verbatim>
<para>
これで、正しい Perl コードをタイプするだけで即座にそれが評価されます。
同様に、シンボルテーブルの検査やスタックのバックトレースを得ること、
変数の値の確認、ブレークポイントの設定、そしてシンボリックデバッガで
行える典型的な操作が可能です。
</para>
</sect2>
<sect2>
<title>Is there a Perl shell?</title>
<para>
(Perlシェルはありますか?)
</para>
<para>
一般的にはなし、です。(Perl と一緒に配布されている)Shell.pm モジュールは、
Perl が Perl 言語の一部ではないコマンドをシェルコマンドのように
試してみるようにさせます。ソース配布と一緒にある perlsh は単純で、
おもしろみに書けるものかもしれませんが、あなたの要求には十分かもしれません。
</para>
</sect2>
<sect2>
<title>How do I debug my Perl programs?</title>
<para>
(私のPerlプログラムをどうやってデバッグするの?)
</para>
<para>
<code>use warning</code> や <code>-w</code>は使いましたか? これらは怪しいところを警告してくれます。
</para>
<para>
<code>use strict</code>を試しましたか? これはシンボリックリファレンスを
使えないようにし、あなたが bareword を使ってサブルーチン呼び出しの前に
宣言を行うようにします。
さらに(これが一番重要なことですが)<code>my</code>, <code>our</code>, <code>use vars</code>を使って
宣言するように強制します。
</para>
<para>
各システムコールの戻り値をチェックしましたか? オペレーティングシステム
(そして Perl)はその呼び出しが成功したかを、
そしてそれがなぜなのかをあなたに返しています。
</para>
<verbatim><![CDATA[
open(FH, "> /etc/cantwrite")
  or die "Couldn't write to /etc/cantwrite: $!\n";
]]></verbatim>
<para>
<link xref='perltrap'>perltrap</link>を読みましたか? そこには古参の Perl プログラマーと
新参の Perl プログラマーに対する gocha がたくさんあります
さらに<emphasis>awk</emphasis>、<emphasis>C</emphasis>のような別の言語から移ってきた人のための
セクションもあります。
</para>
<para>
<link xref='perldebug'>perldebug</link>で説明されているPerlデバッガを試しましたか?
それによりあなたのプログラムをステップ毎に実行することができ、
あなたの思うように働かなかったのがなぜなのかを
調べることができます。
</para>
</sect2>
<sect2>
<title>How do I profile my Perl programs?</title>
<para>
(わたしのPerlプログラムのプロファイルはどうやってとるのでしょう?)
</para>
<para>
You should get the Devel::DProf module from the standard distribution
(or separately on CPAN) and also use Benchmark.pm from the standard 
distribution.  The Benchmark module lets you time specific portions of 
your code, while Devel::DProf gives detailed breakdowns of where your 
code spends its time.
</para>
<para>
標準配付キットにある(CPAN にも分離して置いてあります)
Devel::DProf モジュールを入手して、標準配布キットにある
Benchmark.pm も使ってみるべきでしょう。
ベンチマークは、あなたのプログラムの特定の部分の所要時間を取るのに対して、
Devel::DProf はあなたのプログラムのどこがどのくらい時間を
消費しているのかの詳細を報告します。
</para>
<para>
Here's a sample use of Benchmark:
</para>
<para>
以下は Benchmark の使い方の例です:
</para>
<verbatim><![CDATA[
use Benchmark;
]]></verbatim>
<verbatim><![CDATA[
@junk = `cat /etc/motd`;
$count = 10_000;
]]></verbatim>
<verbatim><![CDATA[
timethese($count, {
          'map' => sub { my @a = @junk;
			   map { s/a/b/ } @a;
			   return @a
			 },
          'for' => sub { my @a = @junk;
			   local $_;
			   for (@a) { s/a/b/ };
			   return @a },
         });
]]></verbatim>
<para>
これは以下のような出力を行います
(あるマシン上の例。ハードウェア、オペレーティングシステム、その時点での
マシンの使用状況によって結果は変わります):
</para>
<verbatim><![CDATA[
Benchmark: timing 10000 iterations of for, map...
       for:  4 secs ( 3.97 usr  0.01 sys =  3.98 cpu)
       map:  6 secs ( 4.97 usr  0.00 sys =  4.97 cpu)
]]></verbatim>
<para>
Be aware that a good benchmark is very hard to write.  It only tests the
data you give it and proves little about the differing complexities
of contrasting algorithms.
</para>
<para>
良いベンチマークを書くのは非常に大変だということに注意してください。
ベンチマークはあなたが与えたデータのみをテストし、複雑なアルゴリズムが
使われたときの複雑さとは異なっているものなのです。
</para>
</sect2>
<sect2>
<title>How do I cross-reference my Perl programs?</title>
<para>
(私のPerlプログラムのクロスリファレンスをとるには?)
</para>
<para>
αリリースのPerlコンパイラー(5.005以前の通常の配布ではありません)とともに
公開されているB::XrefモジュールはPerllプログラムに対する
クロスリファレンスの報告を生成するのに使えます。
</para>
<verbatim><![CDATA[
perl -MO=Xref[,OPTIONS] scriptname.plx
]]></verbatim>
</sect2>
<sect2>
<title>Is there a pretty-printer (formatter) for Perl?</title>
<para>
(Perl用のプリティプリンター(フォーマッター)はどこにあるの?)
</para>
<para>
C に対してindent(1)がやるようなリフォーマットを Perl に対して行うような
プログラムはありません。スキャナーとパーザとの間の複雑な
フィードバック(このフィードバックは vgrind や emacs プログラムを
混乱させるものです)はこれをほとんど Perl パーザを
作るようなものにしています。
</para>
<para>
Of course, if you simply follow the guidelines in <link xref='perlstyle'>perlstyle</link>, you
shouldn't need to reformat.  The habit of formatting your code as you
write it will help prevent bugs.  Your editor can and should help you
with this.  The perl-mode or newer cperl-mode for emacs can provide
remarkable amounts of help with most (but not all) code, and even less
programmable editors can provide significant assistance.  Tom swears
by the following settings in vi and its clones:
</para>
<para>
もちろん、あなたが <link xref='perlstyle'>perlstyle</link>に従っているのであれば、
リフォーマットする必要はないでしょう。自分のプログラムの書式を
統一しておく習慣はバグ対策になります。
あなたの使っているエディターはソースのフォーマッティングを
助けてくれるかもしれません。
emacs の perl モードやより新しい cperl モードは、
コードのほとんど(が、全部ではありません)に対して驚くほどたくさんの手助けを
提供してくれるでしょうし、そしてそれよりも非力なプログラム可能な
エディターでさえも明らかな手助けを提供してくれるかもしれません。
</para>
<para>
Tomはvi(とそのクローン)で以下のような設定を使っています:
</para>
<verbatim><![CDATA[
set ai sw=4
map ^O {^M}^[O^T
]]></verbatim>
<para>
Now put that in your <filename>.exrc</filename> file (replacing the caret characters
with control characters) and away you go.  In insert mode, ^T is
for indenting, ^D is for undenting, and ^O is for blockdenting--
as it were.  If you haven't used the last one, you're missing
a lot.  A more complete example, with comments, can be found at
<xlink uri='http://www.perl.com/CPAN-local/authors/id/TOMC/scripts/toms.exrc.gz'>http://www.perl.com/CPAN-local/authors/id/TOMC/scripts/toms.exrc.gz</xlink>
</para>
<para>
これをあなたの<filename>.exrc</filename>というファイル(キャレットはコントロールキャラクターで
置き換えます)に書き込めば OK です。挿入モードでは^Tはインデントを行い、
^Dはアンインデントを、^Oはblockdentをします。
最後のものを使ったことがないのなら、あなたはこれまで大損をしています。
コメント付きの、より完全な例は
<xlink uri='http://www.perl.com/CPAN-local/authors/id/TOMC/scripts/toms.exrc.gz'>http://www.perl.com/CPAN-local/authors/id/TOMC/scripts/toms.exrc.gz</xlink>
にあります。
</para>
<para>
<emphasis>vgrind</emphasis>プログラムを使ってレーザープリンターにきれいなコードを
出力させるのであれば、
<xlink uri='http://www.perl.com/CPAN/doc/misc/tips/working.vgrind.entry'>http://www.perl.com/CPAN/doc/misc/tips/working.vgrind.entry</xlink>
をスタブとして使うことができますが、その結果は、部分的には、
洗練されたコードではないかもしれません。
</para>
<para>
The a2ps at <xlink uri='http://www.infres.enst.fr/%7Edemaille/a2ps/'>http://www.infres.enst.fr/%7Edemaille/a2ps/</xlink> does lots of things
related to generating nicely printed output of documents.
</para>
<para>
<xlink uri='http://www.infres.enst.fr/%7Edemaille/a2ps/'>http://www.infres.enst.fr/%7Edemaille/a2ps/</xlink> にある a2ps は
奇麗な出力とドキュメントを作るということに関して多くのことを行います。
</para>
</sect2>
<sect2>
<title>Is there a ctags for Perl?</title>
<para>
(Perl用のetags/ctagsはありますか?)
</para>
<para>
There's a simple one at
<xlink uri='http://www.perl.com/CPAN/authors/id/TOMC/scripts/ptags.gz'>http://www.perl.com/CPAN/authors/id/TOMC/scripts/ptags.gz</xlink> which may do
the trick.  And if not, it's easy to hack into what you want.
</para>
<para>
単純なものが
<xlink uri='http://www.perl.com/CPAN/authors/id/TOMC/scripts/ptags.gz'>http://www.perl.com/CPAN/authors/id/TOMC/scripts/ptags.gz</xlink>
にあります。なかったとしても、自分の好みにハックすることは
簡単なことです。
</para>
</sect2>
<sect2>
<title>Is there an IDE or Windows Perl Editor?</title>
<para>
(Perlの統合開発環境とかWindows Perl Editorはありますか?)
</para>
<para>
Perl programs are just plain text, so any editor will do.
</para>
<para>
Perl プログラムは単なるテキストなので、どんなエディタでも作成できます。
</para>
<para>
If you're on Unix, you already have an IDE--Unix itself.  The UNIX
philosophy is the philosophy of several small tools that each do one
thing and do it well.  It's like a carpenter's toolbox.
</para>
<para>
あなたが Unix を使っているなら、あなたはすでに統合開発環境を
手にしています--それは Unix 自身です。
Unix の哲学は、一つのことをうまくこなせる小さなツールを複数
組み合わせることです。
これは大工の道具箱に似ています。
</para>
<para>
If you want a Windows IDE, check the following:
</para>
<para>
Windows の統合開発環境がほしいなら、以下をチェックしてください。
</para>
<list>
<item><itemtext>CodeMagicCD</itemtext>
<para>
<xlink uri='http://www.codemagiccd.com/'>http://www.codemagiccd.com/</xlink>
</para>
</item>
<item><itemtext>Komodo</itemtext>
<para>
ActiveState's cross-platform, multi-language IDE has Perl support,
including a regular expression debugger and remote debugging
(<xlink uri='http://www.ActiveState.com/Products/Komodo/index.html'>http://www.ActiveState.com/Products/Komodo/index.html</xlink>).
(Visual Perl, a Visual Studio.NET plug-in is currently (early 2001)
in beta (<xlink uri='http://www.ActiveState.com/Products/VisualPerl/index.html'>http://www.ActiveState.com/Products/VisualPerl/index.html</xlink>)).
</para>
<para>
ActiveState のクロスプラットフォーム・多言語 IDE は、
正規表現デバッガ、リモートデバッグを含む Perl サポートがあります
(<xlink uri='http://www.ActiveState.com/Products/Komodo/index.html'>http://www.ActiveState.com/Products/Komodo/index.html</xlink>)。
(Visual Perl, Visual Studio.NET プラグインは(2001年初頭)現在
ベータ版です(<xlink uri='http://www.ActiveState.com/Products/VisualPerl/index.html'>http://www.ActiveState.com/Products/VisualPerl/index.html</xlink>))。
</para>
</item>
<item><itemtext>The Object System</itemtext>
<para>
(<xlink uri='http://www.castlelink.co.uk/object_system/'>http://www.castlelink.co.uk/object_system/</xlink>) is a Perl web
applications development IDE.
</para>
<para>
(<xlink uri='http://www.castlelink.co.uk/object_system/'>http://www.castlelink.co.uk/object_system/</xlink>) は Perl web アプリケーション
開発 IDE です。
</para>
</item>
<item><itemtext>PerlBuilder</itemtext>
<para>
(<xlink uri='http://www.solutionsoft.com/perl.htm'>http://www.solutionsoft.com/perl.htm</xlink>) is an integrated development
environment for Windows that supports Perl development.
</para>
<para>
(<xlink uri='http://www.solutionsoft.com/perl.htm'>http://www.solutionsoft.com/perl.htm</xlink>) は Windows 用統合開発環境で、
Perl の開発にも対応しています。
</para>
</item>
<item><itemtext>Perl code magic</itemtext>
<para>
(<xlink uri='http://www.petes-place.com/codemagic.html'>http://www.petes-place.com/codemagic.html</xlink>).
</para>
</item>
<item><itemtext>visiPerl+</itemtext>
<para>
<xlink uri='http://helpconsulting.net/visiperl/'>http://helpconsulting.net/visiperl/</xlink>, from Help Consulting.
</para>
<para>
<xlink uri='http://helpconsulting.net/visiperl/'>http://helpconsulting.net/visiperl/</xlink>, Help Consulting 製です。
</para>
</item>
</list>
<para>
For editors: if you're on Unix you probably have vi or a vi clone already,
and possibly an emacs too, so you may not need to download anything.
In any emacs the cperl-mode (M-x cperl-mode) gives you perhaps the
best available Perl editing mode in any editor.
</para>
<para>
エディタ使いへ: あなたが Unix を使っているなら、おそらく vi か vi クローンが
すでにあるはずで、emacs もあるかもしれません。
それで、あなたは何もダウンロードする必要はないかもしれません。
あらゆるバージョンの emacs で使える cperl-mode (M-x cperl-mode) は
おそらくエディタでの Perl 編集モードの中で最高のものでしょう。
</para>
<para>
For Windows editors: you can download an Emacs
</para>
<para>
Windows のエディタ使いへ: Emacs がダウンロード可能です。
</para>
<list>
<item><itemtext>GNU Emacs</itemtext>
<para>
<xlink uri='http://www.gnu.org/software/emacs/windows/ntemacs.html'>http://www.gnu.org/software/emacs/windows/ntemacs.html</xlink>
</para>
</item>
<item><itemtext>MicroEMACS</itemtext>
<para>
<xlink uri='http://members.nbci.com/uemacs/'>http://members.nbci.com/uemacs/</xlink>
</para>
</item>
<item><itemtext>XEmacs</itemtext>
<para>
<xlink uri='http://www.xemacs.org/Download/index.html'>http://www.xemacs.org/Download/index.html</xlink>
</para>
</item>
</list>
<para>
or a vi clone such as
</para>
<para>
あるいは以下のような vi クローンもあります。
</para>
<list>
<item><itemtext>Elvis</itemtext>
<para>
<xlink uri='ftp://ftp.cs.pdx.edu/pub/elvis/'>ftp://ftp.cs.pdx.edu/pub/elvis/</xlink> <xlink uri='http://www.fh-wedel.de/elvis/'>http://www.fh-wedel.de/elvis/</xlink>
</para>
</item>
<item><itemtext>Vile</itemtext>
<para>
<xlink uri='http://vile.cx/'>http://vile.cx/</xlink>
</para>
</item>
<item><itemtext>Vim</itemtext>
<para>
<xlink uri='http://www.vim.org/'>http://www.vim.org/</xlink>
</para>
<para>
win32: <xlink uri='http://www.cs.vu.nl/%7Etmgil/vi.html'>http://www.cs.vu.nl/%7Etmgil/vi.html</xlink>
</para>
</item>
</list>
<para>
For vi lovers in general, Windows or elsewhere:
<xlink uri='http://www.thomer.com/thomer/vi/vi.html'>http://www.thomer.com/thomer/vi/vi.html</xlink>.
</para>
<para>
一般的な、Windows やその他の vi 愛好者のために:
<xlink uri='http://www.thomer.com/thomer/vi/vi.html'>http://www.thomer.com/thomer/vi/vi.html</xlink>.
</para>
<para>
nvi (<xlink uri='http://www.bostic.com/vi/'>http://www.bostic.com/vi/</xlink>, available from CPAN in src/misc/) is
yet another vi clone, unfortunately not available for Windows, but in
UNIX platforms you might be interested in trying it out, firstly because
strictly speaking it is not a vi clone, it is the real vi, or the new
incarnation of it, and secondly because you can embed Perl inside it
to use Perl as the scripting language.  nvi is not alone in this,
though: at least also vim and vile offer an embedded Perl.
</para>
<para>
nvi (<xlink uri='http://www.bostic.com/vi/'>http://www.bostic.com/vi/</xlink>, CPAN の src/misc/ にもあります)は
vi クローンの一つで、残念ながら Windows では動作しませんが、
UNIX プラットフォームを使っているなら試してみるべきです。
第一の理由としては、厳密には vi クローンではないものの、
実際は vi、あるいは vi の子孫であるからです。
第二の理由としては、Perl を内蔵していて、Perl をスクリプト言語として
使えるからです。しかし、nvi はこれらの機能をもつ唯一のものではありません。
少なくとも vim と vile も内蔵 Perl を提供しています。
</para>
<para>
The following are Win32 multilanguage editor/IDESs that support Perl:
</para>
<para>
以下は Perl をサポートしている Win32 多言語エディタ/IDE です。
</para>
<list>
<item><itemtext>Codewright</itemtext>
<para>
<xlink uri='http://www.starbase.com/'>http://www.starbase.com/</xlink>
</para>
</item>
<item><itemtext>MultiEdit</itemtext>
<para>
<xlink uri='http://www.MultiEdit.com/'>http://www.MultiEdit.com/</xlink>
</para>
</item>
<item><itemtext>SlickEdit</itemtext>
<para>
<xlink uri='http://www.slickedit.com/'>http://www.slickedit.com/</xlink>
</para>
</item>
</list>
<para>
There is also a toyedit Text widget based editor written in Perl
that is distributed with the Tk module on CPAN.  The ptkdb
(<xlink uri='http://world.std.com/~aep/ptkdb/'>http://world.std.com/~aep/ptkdb/</xlink>) is a Perl/tk based debugger that
acts as a development environment of sorts.  Perl Composer
(<xlink uri='http://perlcomposer.sourceforge.net/vperl.html'>http://perlcomposer.sourceforge.net/vperl.html</xlink>) is an IDE for Perl/Tk
GUI creation.
</para>
<para>
CPAN で Tk モジュールと共に配布されている、Perl で書かれた
toyedit Textウィジェットベースのエディタがあります。
ptkdb(<xlink uri='http://world.std.com/~aep/ptkdb/'>http://world.std.com/~aep/ptkdb/</xlink>) は 開発環境として振舞う
Perl/tk ベースのデバッガです。
Perl Composer(<xlink uri='http://perlcomposer.sourceforge.net/vperl.html'>http://perlcomposer.sourceforge.net/vperl.html</xlink>)は
Perl/Tk GUI を使った IDE です。
</para>
<para>
In addition to an editor/IDE you might be interested in a more
powerful shell environment for Win32.  Your options include
</para>
<para>
エディタ/統合開発環境に加えて、Win32 環境でのより強力な
シェル環境に興味があるかもしれません。
選択肢としては以下のものがあります:
</para>
<list>
<item><itemtext>Bash</itemtext>
<para>
from the Cygwin package (<xlink uri='http://sources.redhat.com/cygwin/'>http://sources.redhat.com/cygwin/</xlink>)
</para>
</item>
<item><itemtext>Ksh</itemtext>
<para>
from the MKS Toolkit (<xlink uri='http://www.mks.com/'>http://www.mks.com/</xlink>), or the Bourne shell of
the U/WIN environment (<xlink uri='http://www.research.att.com/sw/tools/uwin/'>http://www.research.att.com/sw/tools/uwin/</xlink>)
</para>
</item>
<item><itemtext>Tcsh</itemtext>
<para>
<xlink uri='ftp://ftp.astron.com/pub/tcsh/'>ftp://ftp.astron.com/pub/tcsh/</xlink>, see also
<xlink uri='http://www.primate.wisc.edu/software/csh-tcsh-book/'>http://www.primate.wisc.edu/software/csh-tcsh-book/</xlink>
</para>
</item>
<item><itemtext>Zsh</itemtext>
<para>
<xlink uri='ftp://ftp.blarg.net/users/amol/zsh/'>ftp://ftp.blarg.net/users/amol/zsh/</xlink>, see also <xlink uri='http://www.zsh.org/'>http://www.zsh.org/</xlink>
</para>
</item>
</list>
<para>
MKS and U/WIN are commercial (U/WIN is free for educational and
research purposes), Cygwin is covered by the GNU Public License (but
that shouldn't matter for Perl use).  The Cygwin, MKS, and U/WIN all
contain (in addition to the shells) a comprehensive set of standard
UNIX toolkit utilities.
</para>
<para>
If you're transferring text files between Unix and Windows using FTP
be sure to transfer them in ASCII mode so the ends of lines are
appropriately converted.
</para>
<para>
On Mac OS the MacPerl Application comes with a simple 32k text editor
that behaves like a rudimentary IDE.  In contrast to the MacPerl Application
the MPW Perl tool can make use of the MPW Shell itself as an editor (with
no 32k limit).
</para>
<list>
<item><itemtext>BBEdit and BBEdit Lite</itemtext>
<para>
are text editors for Mac OS that have a Perl sensitivity mode
(<xlink uri='http://web.barebones.com/'>http://web.barebones.com/</xlink>).
</para>
<para>
これは Mac OS で動作するテキストエディタで、
Perl 用のモードがあります(<xlink uri='http://web.barebones.com/'>http://web.barebones.com/</xlink>)。
</para>
</item>
<item><itemtext>Alpha</itemtext>
<para>
is an editor, written and extensible in Tcl, that nonetheless has
built in support for several popular markup and programming languages
including Perl and HTML (<xlink uri='http://alpha.olm.net/'>http://alpha.olm.net/</xlink>).
</para>
<para>
これはエディタで、Tcl で書かれており、拡張可能です。
それでもいくつかの有名なマークアップ言語とプログラミング言語
(Perl と HTMLを含みます)への対応を内蔵しています(<xlink uri='http://alpha.olm.net/'>http://alpha.olm.net/</xlink>)。
</para>
</item>
</list>
<para>
Pepper and Pe are programming language sensitive text editors for Mac
OS X and BeOS respectively (<xlink uri='http://www.hekkelman.com/'>http://www.hekkelman.com/</xlink>).
</para>
<para>
Pepper と Pe はそれぞれ Mac OS X と BeOS 用のプログラミング言語向け
テキストエディタです(<xlink uri='http://www.hekkelman.com/'>http://www.hekkelman.com/</xlink>)。
</para>
</sect2>
<sect2>
<title>Where can I get Perl macros for vi?</title>
<para>
(vi用のPerlマクロはどこで手に入れられますか?)
</para>
<para>
For a complete version of Tom Christiansen's vi configuration file,
see <xlink uri='http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/toms.exrc.gz'>http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/toms.exrc.gz</xlink> ,
the standard benchmark file for vi emulators.  The file runs best with nvi,
the current version of vi out of Berkeley, which incidentally can be built
with an embedded Perl interpreter--see <xlink uri='http://www.perl.com/CPAN/src/misc'>http://www.perl.com/CPAN/src/misc</xlink>.
</para>
<para>
viエミュレーターの標準ベンチマークファイルである Tom Christiansen の
vi コンフィグレーションファイルの完全なものは 
<xlink uri='http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/toms.exrc.gz'>http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/toms.exrc.gz</xlink>
を見てください。これはBerkeleyの外にあるviのカレントバージョンである
nvi で最もよく実行されます。nvi は組み込みのPerlインタプリタを
つけてビルドすることもできます。
<xlink uri='http://www.perl.com/CPAN/src/misc'>http://www.perl.com/CPAN/src/misc</xlink>
を参照してください。
</para>
</sect2>
<sect2>
<title>Where can I get perl-mode for emacs?</title>
<para>
(emacsのperlモードはどこで入手できますか?)
</para>
<para>
Emacs のバージョン 19 パッチレベル 22 から、perl-mode.el と組み込みの Perl
デバッガをサポートしています。
これらは標準の Emacs19 配布セットと一緒にあるはずです。
</para>
<para>
Perlのソースディレクトリには、“emacs”というディレクトリがあって、
そこにはキーワードをカラー表示したり、コンテキストセンシティブな
ヘルプなどのご機嫌なことを提供するcperl-modeがあります。
</para>
<para>
emacsのperl-modeは<code>“main'foo”</code>(シングルクォート)スタイルを扱うもので、
インデントやハイライトをおかしくしてしまうことに注意してください。
いずれにしろ、<code>“main::foo”</code>を使うべきでしょう。
</para>
</sect2>
<sect2>
<title>How can I use curses with Perl?</title>
<para>
(Perlと一緒にcursesを使うには?)
</para>
<para>
CPANにあるCursesモジュールは、cursesライブラリに対する動的に
ロード可能なオブジェクトモジュールインターフェースを提供します。
ちょっとしたデモが
<xlink uri='http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/rep'>http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/rep</xlink>;
にあります。このプログラムはコマンドを繰り返し、必要に応じて
画面を更新し、<strong>top</strong>と同じく<strong>rep ps axu</strong>をレンダリングします。
</para>
</sect2>
<sect2>
<title>How can I use X or Tk with Perl?</title>
<para>
(どうすればPerlとXやTkを使えますか?)
</para>
<para>
Tkは完全にPerlベースで、Tkを使うためにTclの使用が強制されないような、
Tkツールキットに対するオブジェクト指向インターフェースです。
SxはAthena ウィジェットセットに対するインターフェースです。
これらの両方ともCPANから入手できます。
<xlink uri='http://www.perl.com/CPAN/modules/by-category/08_User_Interfaces/'>http://www.perl.com/CPAN/modules/by-category/08_User_Interfaces/</xlink>
を参照してください。
</para>
<para>
Perl/Tkに関する貴重な情報として、
Perl/Tkに関するFAQが
<xlink uri='http://w4.lns.cornell.edu/%7Epvhp/ptk/ptkTOC.html'>http://w4.lns.cornell.edu/%7Epvhp/ptk/ptkTOC.html</xlink> にあります。
また、
<xlink uri='http://www.perl.com/CPAN-local/authors/Stephen_O_Lidie/'>http://www.perl.com/CPAN-local/authors/Stephen_O_Lidie/</xlink> 
にはPerl/Tkのリファレンスが、
<xlink uri='http://www-users.cs.umn.edu/%7Eamundson/perl/perltk/toc.html'>http://www-users.cs.umn.edu/%7Eamundson/perl/perltk/toc.html</xlink>
にはマニュアルページがあります。
</para>
</sect2>
<sect2>
<title>How can I generate simple menus without using CGI or Tk?</title>
<para>
(どうやれば CGIやTkを使わずに単純なメニューを生成できますか?)
</para>
<para>
cursesベースの
<xlink uri='http://www.perl.com/CPAN/authors/id/SKUNZ/perlmenu.v4.0.tar.gz'>http://www.perl.com/CPAN/authors/id/SKUNZ/perlmenu.v4.0.tar.gz</xlink>
このモジュールが助けになるかもしれません。
</para>
</sect2>
<sect2>
<title>What is undump?</title>
<para>
(undumpってなんですか?)
</para>
<para>
See the next question on ``How can I make my Perl program run faster?''
</para>
<para>
次の質問を参照してください。
</para>
</sect2>
<sect2>
<title>How can I make my Perl program run faster?</title>
<para>
(どうすれば私のPerlプログラムをもっと速くできますか?)
</para>
<para>
その最善の方法とは、よりよいアルゴリズムを使うということです。
ラクダ本の第八章にはあなたが感心をよせるかもしれない幾つかの効率的な
tips があります。
Jon Bentleyの著作“Programming Pearls”(ミススペルではありません!)
(邦訳「珠玉のプログラミング」)にも最適化に関するいくつかの Tips があります。
ベンチマークとプロファイルによって、
あなたのプログラムのどこに手を入れて最適化するのが正しいのかを
はっきりさせ、ちまちまと高速化を行うのではなくより良いアルゴリズムを
探す手掛かりになります。そして、どうしようもなくなったときには
いつ新しいハードウェアを買うかということを知る手掛かりともなります。
</para>
<para>
A different approach is to autoload seldom-used Perl code.  See the
AutoSplit and AutoLoader modules in the standard distribution for
that.  Or you could locate the bottleneck and think about writing just
that part in C, the way we used to take bottlenecks in C code and
write them in assembler.  Similar to rewriting in C,
modules that have critical sections can be written in C (for instance, the
PDL module from CPAN).
</para>
<para>
別のアプローチには、時々使う Perl コードを
オートローディングするというものがあります。
このために標準配布キットにある AutoSplitモジュールと
AutoLoader モジュールを参照してください。
あるいは、ボトルネックとなっているところを特定し、
その部分を C で書くことを考えるかもしれません。
ちょうど C で書かれたプログラムのボトルネックをアセンブラで書くのと同じことです。
C で書き直すという意味では、
クリティカルセクションを持ったモジュールを
C で書き直すというのも同様です(例えば、CPANにある
PDLモジュールがそうです)。
</para>
<para>
幾つかのケースでは、バイトコードを生成したり(これはコンパイル時間を
節約します)Cへコンパイルするようなバックエンドコンパイラーを使う
価値があるかもしれません。これによってコンパイル時間を節約したり
実行時間が小さく(といってもそれほど多くはない)なるでしょう。
Perl プログラムのコンパイルに関する質問を参照してください。
</para>
<para>
もしあなたが今、perlの実行ファイルと共有ライブラリ<code>libc.so</code>を
リンクしているのであれば、スタティックにlibc.aとリンクしてperlを
再ビルドすることによって、10パーセントから25パーセント性能を
向上させることがほとんどの場合可能です。
これはperlの実行ファイルを大きなものにしてしまいますが、
あなたのPerlプログラム(とプログラマー)はスタティックリンクされたことを
感謝するでしょう。
より詳しい情報は、ソース配布にある<filename>INSTALL</filename>というファイルを参照してください。
</para>
<para>
根拠のないレポートが(入出力重視のアプリケーションで)sfio を使っている
Perlインタプリタはそれを使っていないものよりも
高性能であると主張しています。
これを試すには、ソース配布にある<filename>INSTALL</filename>というファイルの、
特に “Selecting File I/O mechanisms” というセクションを参照してください。
</para>
<para>
undump プログラムは、コンパイル済みの形式でディスクに格納することで
Perlプログラムを高速化するのに古くは使われていました。
これはほんの一部のアーキテクチャーでのみ働くものであって、
最早価値ある選択肢ではなく、かつ、よい解決策ではありません。
</para>
</sect2>
<sect2>
<title>How can I make my Perl program take less memory?</title>
<para>
(どうすれば私のPerlプログラムのメモリ消費量を少なくできますか?)
</para>
<para>
時間と空間とを天秤に掛けたとき、Perlはほとんど常にメモリーに関する
問題を放棄します。PerlにおけるスカラーはCの文字列よりもメモリーを消費し、
配列も同様です。ハッシュは更にメモリを使います。
まだ行うことは残ってはいるものの、最近のリリースではこの問題に対処しています。
たとえば5.004にあるように、重複したハッシュキーは全てのハッシュで共有されます。
このため、(そのハッシュキーの格納のための)再割り付けの必要はありません。
</para>
<para>
substr()やvec()を使って配列をシミュレートすることで大幅に効率を
上げられることがあるでしょう。
たとえば千個のブール値を持った配列は、
少なくとも二万バイトの空間を必要とします。
しかし、これを125バイトのビットベクターに置き換えることができます--
これで劇的にメモリを節約できます。
標準のTie::SubstrHashモジュールもデータ構造の幾つかの型に対する助けを
してくれるでしょう。あなたがデータ構造のスペシャリスト
(例えば行列など)モジュールとともに仕事をしようとしているのなら、
Cで実装されたモジュールはPerlで実装された等価なモジュールよりも
少ないメモリしか使わないでしょう。
</para>
<para>
試してみるべきもう一つの事柄は、あなたの使っているPerlがシステムの
mallocを使っているのかPerl組み込みのmallocを使っているのかを知ることです。
いずれを使っているにしろ、別のものを使うようにしてみてそれによる差を確かめます。
mallocに関する情報はソース配布にある<filename>INSTALL</filename>というファイルにあります。
<code>perl -V:usemymalloc</code>とタイプすればperlが使っている
mallocがどちらであるかを知ることができます。
</para>
</sect2>
<sect2>
<title>Is it unsafe to return a pointer to local data?</title>
<para>
(ローカルなデータへのポインターを返すことは危険ですか?)
</para>
<para>
いいえ。Perlのガーベッジコレクションシステムはそれを気をつけて扱います。
</para>
<verbatim><![CDATA[
sub makeone {
	my @a = ( 1 .. 10 );
	return \@a;
}
]]></verbatim>
<verbatim><![CDATA[
for $i ( 1 .. 10 ) {
    push @many, makeone();
}
]]></verbatim>
<verbatim><![CDATA[
print $many[4][5], "\n";
]]></verbatim>
<verbatim><![CDATA[
print "@many\n";
]]></verbatim>
</sect2>
<sect2>
<title>How can I free an array or hash so my program shrinks?</title>
<para>
(どうすれば、配列やハッシュを解放して私のプログラムを小さくできますか?)
</para>
<para>
それはできません。ほとんどのシステムでは、プログラムのために
割り付けたメモリーは、決してシステムに返されることはありません。
これは、長期間動作しているプログラムが時々自分自身を
再起動する理由でもあります。
一部のオペレーティングシステム(特にFreeBSD)では、
最早使われていないメモリーの塊をまとめているらしいのですが、
それは(現時点では)Perlには影響を及ぼしません。
MacはOSに返却したメモリーの回収が信用できる
(遅いという問題はあるものの)
只一つのプラットフォームのようです。
</para>
<para>
私たちはIntel用Linux(Redhat 5.1)において、<code>undef $scalar</code>が
システムにメモリーを返却するという報告を受けています。一方で
Solaris2.6はそのような動作はしないようです。
一般的には自分で試してみるということになるでしょう。
</para>
<para>
しかしながら、変数に対して賢明なmy()の使用をすることで、
それらの変数がスコープからはずれたときにPerlがそれらが使っていた領域を
解放してプログラムの他の部分で使えるようにする助けになります。
もちろんグローバル変数は決してスコープから外れることはなく、そのため、
undef()やdeleteを使って同様のことができるにもかかわらず、それらの
空間を自動的に取り戻すようなことはできません。
一般的には、メモリ割り付けと解放はあなたが扱えることではなく、
データ型の先行割り付け(preallocation)がうまくいっていたとしても
Perlがどうやっているかを心配すべきものです。
</para>
</sect2>
<sect2>
<title>How can I make my CGI script more efficient?</title>
<para>
(どうやれば私のCGIスクリプトをもっと効率よくできますか?)
</para>
<para>
普通のPerlプログラムを速くしたり小さくしたりするための基準とは別に、
CGIプログラムには更に別の基準があります。
CGIプログラムは一秒に数回実行される可能性があります。
実行する度毎にスクリプトの再コンパイルとシステムメモリーを
一メガバイト以上割りつけることが必要となります。これは問題点となり得ます。
Cへコンパイルすることは<strong>助けにはなりません</strong>。
なぜなら、プロセスのスタートアップ時のオーバーヘッドがボトルネックだからです。
</para>
<para>
このオーバーヘッドを避けるためのポピュラーな手段が二つあります。
解決策の一つはApache HTTPサーバー(<xlink uri='http://www.apache.org/'>http://www.apache.org/</xlink>から入手可能)に
mod_perlかmod_fastcgiのいずれかのプラグインモジュールを
取り込ませて実行させるというものです。
</para>
<para>
mod_perlとApache::Registry モジュール(mod_perlと一緒に配布されて
います)と組み合わせることで、httpdは組み込みのPerl
インタプリタと共に実行させるようになります。
これで、あなたのスクリプトは事前にコンパイルされ、
それをfork抜きで同じアドレス空間で実行されるようになります。
Apatche エクステンションはまた、
Perlに内部サーバーAPIをアクセスすることを許可するので、
Perlで記述されたモジュールはCで書かれたモジュールができることはなんでも
できるようになります。
mod_perlに関する詳細は <xlink uri='http://perl.apache.org/'>http://perl.apache.org/</xlink> を参照してください。
</para>
<para>
FCGIモジュール(CPANにあります)と
mod_fastcgiモジュール(<xlink uri='http://www.fastcgi.com'>http://www.fastcgi.com</xlink>で入手できます)
はあなたのPerlプログラムのそれぞれを永続的 CGI デーモンプロセスにします。
</para>
<para>
これらの解決策は両方ともあなたの使うシステムで効果がない可能性があり、
また、あなたが書いたCGIプログラムに依存する方法なので、
注意して検査してください。
</para>
<para>
<xlink uri='http://www.perl.com/CPAN/modules/by-category/15_World_Wide_Web_HTML_HTTP_CGI/'>http://www.perl.com/CPAN/modules/by-category/15_World_Wide_Web_HTML_HTTP_CGI/</xlink> 
を参照してください。
</para>
<para>
A non-free, commerical product, ``The Velocity Engine for Perl'',
(<xlink uri='http://www.binevolve.com/'>http://www.binevolve.com/</xlink> or <xlink uri='http://www.binevolve.com/velocigen/'>http://www.binevolve.com/velocigen/</xlink> )
might also be worth looking at.  It will allow you to increase the
performance of your Perl programs, running programs up to 25 times
faster than normal CGI Perl when running in persistent Perl mode or 4
to 5 times faster without any modification to your existing CGI
programs. Fully functional evaluation copies are available from the
web site.
</para>
<para>
フリーソフトではない、商用の製品の``The Velocity Engine for Perl''
があります(<xlink uri='http://www.binevolve.com/'>http://www.binevolve.com/</xlink> または <xlink uri='http://www.binevolve.com/velocigen/'>http://www.binevolve.com/velocigen/</xlink>)。
これがお望みのものかもしれません。
これはまた、あなたのPerlプログラムの性能を引き上げ、
persistent Perlモードで実行されている
通常のCGI Perlの25倍の早さにすることもありますし、
すでにあるCGIプログラムも何も変更せずに四倍から五倍早いものに
します。機能が全て使える評価版が先のwebサイトで入手可能です。
</para>
</sect2>
<sect2>
<title>How can I hide the source for my Perl program?</title>
<para>
(どうやれば私のPerlプログラムのソースを隠せるでしょうか?)
</para>
<para>
削除しましょう :-) まじめな話、様々な“セキュリティ”レベルを持った
幾つかの解決策があります(ほとんどは満足行くものではないでしょう)。
</para>
<para>
First of all, however, you <emphasis>can't</emphasis> take away read permission, because
the source code has to be readable in order to be compiled and
interpreted.  (That doesn't mean that a CGI script's source is
readable by people on the web, though--only by people with access to
the filesystem.)  So you have to leave the permissions at the socially
friendly 0755 level.
</para>
<para>
しかしながら、まず最初に、あなたは読み取り権限(read permission)を
落とすことはできません。
なぜなら、スクリプトのソースコードはコンパイルとインタープリットのために
読み取り可能でなければならない
からです(これはCGIスクリプトのソースコードがweb上で、
読み取り可能であることとは違います--
ファイルシステムに対してアクセスできる人だけが読み取り可能です)。
ですから、権限の設定を少なくとも socially friendly な 0755 の
レベルにしておく必要があります。
</para>
<para>
中にはこれをセキュリティ上の問題であると考えている人もいます。
あなたのプログラムが安全でないことを行った場合、
そして、人々がそのような安全でないことを暴露する方法を知らないことに
頼っているのなら、安全ではないのです。
誰かが、安全でないことを見つけだすこととソースを見ることなしにそれを
暴露することはしばしば可能となるのです。
セキュリティバグを直すのではなくてそのバグを隠すといった、
知られていないことに頼るセキュリティ(security through obscurity)は
小さなセキュリティの傷です。
</para>
<para>
ソースフィルター(CPANで入手可能なFilter::*)を使った暗号化を試すこともできます。
しかし、悪意在るプログラマーはそれを複号化できるかもしれません。
あなたはバイトコードコンパイラーとインタプリタを
(上で説明したように)使うことを試せるかもしれませんが、
探りたがりの人はそれを逆コンパイルできるかもしれません。
(上で説明したような)ネイティブコードコンパイラーを試すこともできますが、
クラッカーはそれを逆アセンブルできるかもしれません。
これらの手段は、あなたのプログラムを手に入れようとする人達に様々な困難を
もたらしますが、
誰もそれを決定的に防ぐ障壁にすることはできないのです(Perlのみに
限らず、あらゆる言語で真となります)。
</para>
<para>
あなたが、誰かがあなたのプログラムを元になにか利益を
得るのではないかということを考えているのなら、
プログラムの最後の行を制限付きライセンスとすれば、
あなたに法的な安全性 (legal security)をもたらすでしょう。
あなたのソフトウェアをライセンスし、
“This is unpublished proprietary software of XYZ Corp.
Your access to it does not give you permission to use it blah blah
blah.”
(本ソフトウェアは、XYZコーポレイションにより作成された非公開の
独占的ソフトウェアです。あなたがこれにアクセスすることは許されていません、
云々)のような文章で味付けします。もちろん私たちは弁護士ではありませんから、
あなたが確実に自分のライセンスが有効なものになるようにしたいのなら、
弁護士に会っておくべきでしょう。
</para>
</sect2>
<sect2>
<title>How can I compile my Perl program into byte code or C?</title>
<para>
(どうやれば私のPerlプログラムをバイトコードやCへコンパイルできますか?)
</para>
<para>
Malcolm Beattieは多機能バックエンドコンパイラー(multifunction
backend compiler)を作成しました。
これはCPANで入手することができ質問の両方ともを行えます。
このコンパイラーはperl5.005のリリースに
含まれていますが、まだまだ実験段階のもので、
あなたがプログラマーであるなら使って遊ぶこともできますが、
プログラマーでない人々が望んでいるものではありません。
</para>
<para>
Merely compiling into C does not in and of itself guarantee that your
code will run very much faster.  That's because except for lucky cases
where a lot of native type inferencing is possible, the normal Perl
run-time system is still present and so your program will take just as
long to run and be just as big.  Most programs save little more than
compilation time, leaving execution no more than 10-30% faster.  A few
rare programs actually benefit significantly (even running several times
faster), but this takes some tweaking of your code.
</para>
<para>
Cコードへの単なる変換はあなたのプログラムをより早く実行するように
するものではありません。なぜならそれは、内部型(native type)の
インタフェースの数多くがが使用可能であるという幸運な場合を除き、
通常のPerlのランタイムシステムはまだ(プログラムの中に)存在していて、
それによってあなたのプログラムはその大きさに応じた分だけ
起動に時間がかかるからなのです。
ほとんどのプログラムはコンパイル時間程の節約しかできず、
実行時間はせいぜいが10から30%程度でしょう。
ほんの一部のプログラムは目に見えるような改善が得られるでしょう
(何倍も早くなることもあります)が
あなたのプログラムを少々ひねくり回すことになります。
</para>
<para>
コンパイラーのカレントバージョンが、オリジナルのPerlの実行ファイルと
同じくらいの大きさのコンパイル済みスクリプトを生成することを
知ってびっくりするかもしれません。
これは、現在のものでは全てのプログラムが全体がeval()文で囲まれているかのように
扱われているからです。
これは、共有ライブラリ <emphasis>libperl.so</emphasis>を作成してそれを使うようにすることで
劇的に小さくすることができます。
詳しくは、Perlのソース配布キットにある <filename>INSTALL</filename>というpodfileを
参照してください。
あなたの使っている perl バイナリをこのライブラリとリンクすれば、
perlバイナリを取るに足らないくらい小さくします。
たとえば、ある著者のシステムでは、/usr/bin/perl はたったの11kバイトの
大きさでしかないのです!
</para>
<para>
In general, the compiler will do nothing to make a Perl program smaller,
faster, more portable, or more secure.  In fact, it can make your
situation worse.  The executable will be bigger, your VM system may take
longer to load the whole thing, the binary is fragile and hard to fix,
and compilation never stopped software piracy in the form of crackers,
viruses, or bootleggers.  The real advantage of the compiler is merely
packaging, and once you see the size of what it makes (well, unless
you use a shared <emphasis>libperl.so</emphasis>), you'll probably want a complete
Perl install anyway.
</para>
<para>
一般的にいって、コンパイラーはPerlプログラムを小さくもしませんし、
早くもしなければ、移植性を増すこともせず、安全にもしません。
実際、状況がより悪くなることもあります。
実行ファイルは大きくなり、あなたの使うVMシステムは全体をロードするのに
より時間を要すようになりますし、バイナリコードは壊れやすくて
修整しにくいものです。
そして、コンパイルはソフトウェアの不法使用者のクラッキングも、ウィルスも、
密売も防ぐことはできません。
コンパイラーの本当の有利な点は、単にパッケージングということで、
出来上がった実行ファイルの大きさ(まあ、<emphasis>libperl.so</emphasis>共有ライブラリを
使った場合は別ですが)を見てしまえば、Perl全体をインストールしてしまおうと
思うかもしれません。
</para>
</sect2>
<sect2>
<title>How can I compile Perl into Java?</title>
<para>
(どうやればPerlをJavaにコンパイルできますか?)
</para>
<para>
You can also integrate Java and Perl with the
Perl Resource Kit from O'Reilly and Associates.  See
<xlink uri='http://www.oreilly.com/catalog/prkunix/'>http://www.oreilly.com/catalog/prkunix/</xlink> .
</para>
<para>
オライリーの Perl リソースキットを使って Java と Perl を統合することも出来ます。
<xlink uri='http://www.oreilly.com/catalog/prkunix/'>http://www.oreilly.com/catalog/prkunix/</xlink> を参照してください。
</para>
<para>
Perl 5.6 comes with Java Perl Lingo, or JPL.  JPL, still in
development, allows Perl code to be called from Java.  See jpl/README
in the Perl source tree.
</para>
<para>
Perl 5.6 は Java Perl Lingo(JPL) と協調できます。
JPL はまだ開発中ですが、Perl コードを Java から呼び出せます。
Perl ソースツリーの jpl/README を参照してください。
</para>
</sect2>
<sect2>
<title>How can I get '#!perl' to work on [MS-DOS,NT,...]?</title>
<para>
(MS-DOS, NT, etc で '#!perl'が動作するようにするには?)
</para>
<para>
OS/2では
</para>
<verbatim><![CDATA[
extproc perl -S -your_switches
]]></verbatim>
<para>
<code>(*.cmd</code>ファイルの先頭をこのようにするだけです(<code>-S</code>は、
cmd.exeの`extproc'に関するバグのためです)。DOSの場合は、適切なバ
ッチファイルを作って<code>ALTERNATIVE_SHEBANG</code> を行うべきでしょう(詳
細は、ソース配布キットにある<filename>INSTALL</filename>というファイルを参照してくだ
さい)。
</para>
<para>
The Win95/NT installation, when using the ActiveState port of Perl,
will modify the Registry to associate the <code>.pl</code> extension with the
perl interpreter.  If you install another port, perhaps even building
your own Win95/NT Perl from the standard sources by using a Windows port
of gcc (e.g., with cygwin or mingw32), then you'll have to modify
the Registry yourself.  In addition to associating <code>.pl</code> with the
interpreter, NT people can use: <code>SET PATHEXT=%PATHEXT%;.PL</code> to let them
run the program <code>install-linux.pl</code> merely by typing <code>install-linux</code>.
</para>
<para>
Windows 95やWindows NTで ActiveStateの移植したPerl
を使うのなら、これは<code>.pl</code>という拡張子をperlインタプリタに関連
づけるようにレジストリを変更します。その他の移植になるperl
を使うか、あるいはあなた自身が Windowsに移植されたgcc(cygwinやmingw)を
使って標準ソースからPerlをビルドするというの
であれば自分自身でレジストリを変更する必要があるでしょう。
<code>.pl</code>とインタプリタを関連づけることによって、NTを使っている
人は<code>install-linux.pl</code> を <code>install-linux</code>のように起動することが
可能です。NTでは<code>SET PATHEXT=%PATHEXT%;.PL</code>のようにします。
</para>
<para>
Macintosh Perl programs will have the appropriate Creator and
Type, so that double-clicking them will invoke the Perl application.
</para>
<para>
Macintosh Perlのプログラムは適切なCreatorとTypeとを持っているで
しょうから、ダブルクリックするだけでPerlアプリケーシ
ョンが起動するでしょう。
</para>
<para>
<strong>重要!</strong>:あなたが何をするにしても、どうか不満を感じないでください。
そして、あなたのプログラムがwebサーバのために動作するようにさせ
るためにperlインタプリタをcgi-binディレクトリに放り込むよう
なことはしないでください。これは<strong>非常に</strong>大きなセキュリティ上の
リスクとなります。正しく動作させるための方法を考えるための時間を
取ってください。
</para>
</sect2>
<sect2>
<title>Can I write useful perl programs on the command line?</title>
<para>
(コマンドライン上で便利なperlプログラムを書けますか?)
</para>
<para>
できます。詳しくは<link xref='perlrun'>perlrun</link>を読んでください。幾つかのサンプルを
以下に挙げておきます(ここでは標準のUNIX シェル引用規則に従っていると
仮定します)。
</para>
<verbatim><![CDATA[
# 最初と最後のフィールドを加算する
perl -lane 'print $F[0] + $F[-1]' *
]]></verbatim>
<verbatim><![CDATA[
# テキストファイルを見つけだす
perl -le 'for(@ARGV) {print if -f && -T _}' *
]]></verbatim>
<verbatim><![CDATA[
# Cプログラムから(大部分の)コメントを取り除く
perl -0777 -pe 's{/\*.*?\*/}{}gs' foo.c
]]></verbatim>
<verbatim><![CDATA[
# ファイルの修整日付を今日より一月先にして、reaper daemonを打ち負かす
perl -e '$X=24*60*60; utime(time(),time() + 30 * $X,@ARGV)' *
]]></verbatim>
<verbatim><![CDATA[
# 最初の未使用uidを見つけだす
perl -le '$i++ while getpwuid($i); print $i'
]]></verbatim>
<verbatim><![CDATA[
# 適切なmanpathを表示する
echo $PATH | perl -nl -072 -e '
	s![^/+]*$!man!&&-d&&!$s{$_}++&&push@m,$_;END{print"@m"}'
]]></verbatim>
<para>
そう、最後のは Obfuscated Perl コンテストにエントリーされてましたね :-)
</para>
</sect2>
<sect2>
<title>Why don't Perl one-liners work on my DOS/Mac/VMS system?</title>
<para>
(なぜ私の DOS/Mac/VMSシステムでは一行野郎(one-liners)は動かないのでしょうか?)
</para>
<para>
この問題は、そういったシステムのコマンドインタプリタが、
一行野郎が作られた環境であるUNIXのシェルの引用規則とは異なるこということです。
一部のシステムでは、シングルクォートをダブルクォートに
変更する必要があるかもしれません(これはUNIXやPlan9といったシステムでは
<strong>してはいけません</strong>)。
同様に、%を%%に変更する必要もあるかもしれません。
</para>
<para>
例を挙げましょう:
</para>
<verbatim><![CDATA[
# Unix
perl -e 'print "Hello world\n"'
]]></verbatim>
<verbatim><![CDATA[
# DOSなど
perl -e "print \"Hello world\n\""
]]></verbatim>
<verbatim><![CDATA[
# Mac
print "Hello world\n"
 (then Run "Myscript" or Shift-Command-R)
]]></verbatim>
<verbatim><![CDATA[
# VMS
perl -e "print ""Hello world\n"""
]]></verbatim>
<para>
問題は、これらの例の中に信頼できるものがないということです:
コマンドインタープリタに依存します。
UNIXでは、最初の二つはほとんどの場合動作するでしょう。
DOSでは、どれも働かないかもしれません。
4DOSをコマンドシェルとしているのなら、以下のようにするのがよいと思います:
</para>
<verbatim><![CDATA[
perl -e "print <Ctrl-x>"Hello world\n<Ctrl-x>""
]]></verbatim>
<para>
Macでは、あなたが使っている環境に依存します。
MacPerlシェルやMPWは、制御キャラクターのようなMacの非ASCIIキャラクターが
自由に使えるという点を除いて、
UNIXシェルのように数種類の引用規則をサポートします。
</para>
<para>
ダブルクォート(&quot;)、シングルクォート(')、バッククォート(`)の
代わりにqq(), q(), qx()をそれぞれ使います。これによって
一行野郎を書くことが簡単になるかもしれません。
</para>
<para>
There is no general solution to all of this.  It is a mess, pure and
simple.  Sucks to be away from Unix, huh? :-)
</para>
<para>
この件全てに関する一般的な解決策はありません。ごちゃごちゃで、
純粋で、単純です。Unix から離れたくなくなったでしょう? :-)
</para>
<para>
[この回答の一部はKenneth Albanowskiから寄せられました]
</para>
</sect2>
<sect2>
<title>Where can I learn about CGI or Web programming in Perl?</title>
<para>
(わたしがPerlによるCGIやWebプログラミングについて学べる場所は?)
</para>
<para>
モジュールなら、CPANからCGIモジュールやLWPモジュールを入手しましょう。
教科書なら、本にあるweb stuffの特に決定的な二つを参照しましょう。
“Why do I get 500 Errors” (なんで 500 Errors になるの)
“Why doesn't it run from the browser right when it runs fine on the command line”
(なぜコマンドラインからだとちゃんと動くのに、ブラウザーからだと
だめなんでしょうか)のようにwebに関連する問題や疑問は以下のソースを
参照してください。
</para>
<verbatim><![CDATA[
WWW Security FAQ
    http://www.w3.org/Security/Faq/
]]></verbatim>
<verbatim><![CDATA[
Web FAQ
    http://www.boutell.com/faq/
]]></verbatim>
<verbatim><![CDATA[
CGI FAQ
    http://www.webthing.com/page.cgi/cgifaq.html
]]></verbatim>
<verbatim><![CDATA[
HTTP Spec
    http://www.w3.org/pub/WWW/Protocols/HTTP/
]]></verbatim>
<verbatim><![CDATA[
HTML Spec
    http://www.w3.org/TR/REC-html40/
    http://www.w3.org/pub/WWW/MarkUp/
]]></verbatim>
<verbatim><![CDATA[
CGI Spec
    http://www.w3.org/CGI/
]]></verbatim>
<verbatim><![CDATA[
CGI Security FAQ
    http://www.go2net.com/people/paulp/cgi-security/safe-cgi.txt
]]></verbatim>
</sect2>
<sect2>
<title>Where can I learn about object-oriented Perl programming?</title>
<para>
(オブジェクト指向のPerlプログラミングはどこで学べますか?)
</para>
<para>
A good place to start is <link xref='perltoot'>perltoot</link>, and you can use <link xref='perlobj'>perlobj</link>,
<link xref='perlboot'>perlboot</link>, and <link xref='perlbot'>perlbot</link> for reference.  Perltoot didn't come out
until the 5.004 release; you can get a copy (in pod, html, or
postscript) from <xlink uri='http://www.perl.com/CPAN/doc/FMTEYEWTK/'>http://www.perl.com/CPAN/doc/FMTEYEWTK/</xlink> .
</para>
<para>
始めるにはよい場所は <link xref='perltoot'>perltoot</link>です。リファレンスとして<link xref='perlobj'>perlobj</link>,
<link xref='perlboot'>perlboot</link>, &lt;perlbot&gt;が使えます。
perltoot はリリース5.004までは添付されていませんでした。
そのコピーを
<xlink uri='http://www.perl.com/CPAN/doc/FMTEYEWTK/'>http://www.perl.com/CPAN/doc/FMTEYEWTK/</xlink> 
から入手することが可能です。
</para>
</sect2>
<sect2>
<title>Where can I learn about linking C with Perl? [h2xs, xsubpp]</title>
<para>
(C と Perl のリンクについてはどこで学べますか? [h2xs, xsubpp])
</para>
<para>
もしPerlからCを呼び出したいのなら、<link xref='perlxstut'>perlxstut</link>から始めて<link xref='perlxs'>perlxs</link>, 
<link xref='xsubpp'>xsubpp</link>, <link xref='perlguts'>perlguts</link>へと進みます。CからPerlを呼び出したいのなら、
<link xref='perlembed'>perlembed</link>, <link xref='perlcall'>perlcall</link>, <link xref='perlguts'>perlguts</link>を読みましょう。
すでにあるエクステンションの作者がどのようにそれを記述し、
どのように彼らの問題を解決したのかを見ることで多くのことが
学べるのだということを忘れないでください。
</para>
</sect2>
<sect2>
<title>I've read perlembed, perlguts, etc., but I can't embed perl in
my C program; what am I doing wrong?</title>
<para>
(perlembedやperlgutsなんかを読んだのだけど、
私のCプログラムにperlを組み込めません。
何が悪いのでしょうか?)
</para>
<para>
CPANからExtUtils::Embedキットをダウンロードして、`make test'を
実行してください。
もしこのテストに合格したのなら、podを何度も何度もくり返しくり返し
読んでください。
テストに失敗したなら、<link xref='perlbug'>perlbug</link>を読んで、<code>perl -V</code>の出力と
<code>make test TEST_VERBOSE=1</code>の出力を添付してバグレポートを送ってください。
</para>
</sect2>
<sect2>
<title>When I tried to run my script, I got this message. What does it
mean?</title>
<para>
(私のスクリプトを実行したとき、こんなメッセージを受け取りました。
これって何を意味しているのでしょうか?)
</para>
<para>
A complete list of Perl's error messages and warnings with explanatory
text can be found in <link xref='perldiag'>perldiag</link>. You can also use the splain program
(distributed with Perl) to explain the error messages:
</para>
<para>
perl のすべてのエラーメッセージ、警告メッセージの説明テキスト付きのリストが
<link xref='perldiag'>perldiag</link> にあります。
エラーメッセージを説明するために、
splain プログラムを使うこともできます(これは Perl と一緒に配布されています)。
</para>
<verbatim><![CDATA[
perl program 2>diag.out
splain [-v] [-p] diag.out
]]></verbatim>
<para>
あるいは、メッセージを説明的にするようにプログラムを変更します。
</para>
<verbatim><![CDATA[
use diagnostics;
]]></verbatim>
<para>
or
</para>
<para>
あるいはこう
</para>
<verbatim><![CDATA[
use diagnostics -verbose;
]]></verbatim>
</sect2>
<sect2>
<title>What's MakeMaker?</title>
<para>
(MakeMakerってなんですか?)
</para>
<para>
このモジュール(標準Perl配布キットの一部です)はMakefile.PLから
エクステンションモジュール用のMakefileを作成するために
デザインされたものです。
詳しくは <link xref='ExtUtils::MakeMaker'>ExtUtils::MakeMaker</link> を参照してください。
</para>
</sect2>
</sect1>
<sect1>
<title>AUTHOR AND COPYRIGHT</title>
<para>
Copyright (c) 1997-1999 Tom Christiansen and Nathan Torkington.
All rights reserved.
</para>
<para>
When included as an integrated part of the Standard Distribution
of Perl or of its documentation (printed or otherwise), this works is
covered under Perl's Artistic License.  For separate distributions of
all or part of this FAQ outside of that, see <link xref='perlfaq'>perlfaq</link>.
</para>
<para>
Irrespective of its distribution, all code examples here are in the public
domain.  You are permitted and encouraged to use this code and any
derivatives thereof in your own programs for fun or for profit as you
see fit.  A simple comment in the code giving credit to the FAQ would
be courteous but is not required.
</para>
<para>
Translate: 吉村 寿人 &lt;JAE00534@niftyserve.or.jp&gt;
Update: Kentaro Shirakata &lt;argrath@ub32.org&gt;
License: GPL or Artistic
</para>
</sect1>
</pod>
