[perldocjp-cvs 1529] CVS update: docs/articles/qntm.org/files/perl

Back to archive index

ktats****@users***** ktats****@users*****
2012年 9月 1日 (土) 01:59:01 JST


Index: docs/articles/qntm.org/files/perl/perl.html
diff -u docs/articles/qntm.org/files/perl/perl.html:1.5 docs/articles/qntm.org/files/perl/perl.html:1.6
--- docs/articles/qntm.org/files/perl/perl.html:1.5	Fri Aug 31 01:35:20 2012
+++ docs/articles/qntm.org/files/perl/perl.html	Sat Sep  1 01:58:59 2012
@@ -1015,7 +1015,9 @@
 <h3 class=original>In-place array modification</h3>
 <h3>その場で配列を変更する</h3>
 
-<p>We'll use <tt>@stack</tt> to demonstrate these:</p>
+<p class="original">We'll use <tt>@stack</tt> to demonstrate these:</p>
+
+<p><tt>@stack</tt>を使ってデモします:</p>
 
 <pre class="perl prettyprint">
 my @stack = ("Fred", "Eileen", "Denise", "Charlie");
@@ -1424,8 +1426,8 @@
 export PERL5LIB=/foo/bar/baz:$PERL5LIB
 </pre>
 
-<p>Once the Perl module is created and <tt>perl</tt> knows where to look for it, you can use the <tt>require</tt> built-in function to search for and execute it during a Perl script. For example, calling <tt>require Mathematics::Powers</tt> causes the Perl interpreter to search each directory listed in <tt>PERL5LIB</tt> in turn, looking for a file called <tt>Mathematics/Powers.pm</tt>. After the module has been loaded, the subroutines and variables that were defined there suddenly become available in the main script. Our example script might be called <tt>powers.pl</tt> and read as follows:</p>
-<p class=original>Perlモジュールが作られて、<tt>perl</tt>がそれがどこにあるかを知っていれば、組込の<tt>require</tt>関数を使って探し、Perlのスクリプト中で実行することができます。例えば、<tt>require Mathematics::Powers</tt>を呼ぶと、Perlインタープリタは<tt>PERL5LIB</tt>にリストされているディレクトリを順番に、<tt>Mathematics/Powers.pm</tt>というファイルを探します。モジュールがロードされたら、突然にサブルーチンと変数がメインスクリプトに定義されます。この例のスクリプトを<tt>powers.pl</tt>と呼びましょう。続けて読んでくさい:</p>
+<p class=original>Once the Perl module is created and <tt>perl</tt> knows where to look for it, you can use the <tt>require</tt> built-in function to search for and execute it during a Perl script. For example, calling <tt>require Mathematics::Powers</tt> causes the Perl interpreter to search each directory listed in <tt>PERL5LIB</tt> in turn, looking for a file called <tt>Mathematics/Powers.pm</tt>. After the module has been loaded, the subroutines and variables that were defined there suddenly become available in the main script. Our example script might be called <tt>powers.pl</tt> and read as follows:</p>
+<p>Perlモジュールが作られて、<tt>perl</tt>がそれがどこにあるかを知っていれば、組込の<tt>require</tt>関数を使って探し、Perlのスクリプト中で実行することができます。例えば、<tt>require Mathematics::Powers</tt>を呼ぶと、Perlインタープリタは<tt>PERL5LIB</tt>にリストされているディレクトリを順番に、<tt>Mathematics/Powers.pm</tt>というファイルを探します。モジュールがロードされたら、突然にサブルーチンと変数がメインスクリプトに定義されます。この例のスクリプトを<tt>powers.pl</tt>と呼びましょう。続けて読んでくさい:</p>
 
 <pre class="perl prettyprint">
 use strict;
@@ -1439,27 +1441,43 @@
 <p class=original>Now read this next bit carefully.</p>
 <p>では、次はちょっと注意して読んでください。</p>
 <p class=original>Packages and modules are two completely separate and distinct features of the Perl programming language. The fact that they both use the same double colon delimiter is a monumental red herring. It is possible to switch packages multiple times over the course of a script or module, and it is possible to use the same package declaration in multiple locations in multiple files. Calling <tt>require Foo::Bar</tt> <em>does not</em> look for and load a file with a <tt>package Foo::Bar</tt> declaration somewhere inside it. Calling <tt>require Foo::Bar</tt> <em>does not</em> necessarily load subroutines or package variables in the <tt>Foo::Bar</tt> namespace. Calling <tt>require Foo::Bar</tt> merely loads a file called <tt>Foo/Bar.pm</tt>, which need not have <em>any</em> kind of package declaration inside it at all, and in fact might declare <tt>package Baz::Qux</tt> and other nonsense inside it for all you know.</p>
-<p>パッケージとモジュールの2つは、プログラミング言語Perlにおいて完全に分かれており、区別された機能です。この2つが同じダブルコロンのデリミタを使っていることは、記念碑的な赤ニシンです。これは、スクリプトまたはモジュールのコース経由でパッケージを複数回切り替えることができ、また、複数のファイル内の複数の場所で同一のパッケージ宣言を使うこともできます。<tt>require Foo::Bar</tt>を呼ぶことは<tt>Foo::Bar</tt>名前空間にあるサブルーチンやパッケージ変数を必ずしもロード<em>しません</em>。<tt>require Foo::Bar</tt>を呼ぶことは、単に<tt>Foo/Bar.pm</tt>というファイルをロードするだけであり、そのファイルに、<em>どのような</em>種類のパッケージ宣言も必要有りません。実際には、あなたの知っている全ての<tt>package Baz
 ::Qux</tt>のような意味のないものも宣言できます。</p>
+<p>パッケージとモジュールの2つは、プログラミング言語Perlにおいて完全に分かれており、区別された機能です。この2つが同じダブルコロンのデリミタを使っていることは、重要なひっかけです。これは、スクリプトまたはモジュールのコース経由でパッケージを複数回切り替えることができ、また、複数のファイル内の複数の場所で同一のパッケージ宣言を使うこともできます。<tt>require Foo::Bar</tt>を呼ぶことは<tt>Foo::Bar</tt>名前空間にあるサブルーチンやパッケージ変数を必ずしもロード<em>しません</em>。<tt>require Foo::Bar</tt>を呼ぶことは、単に<tt>Foo/Bar.pm</tt>というファイルをロードするだけであり、そのファイルに、<em>どのような</em>種類のパッケージ宣言も必要有りません。実際には、<tt>package Baz::Qux</tt>のような意味のないもã
 ®ã‚‚宣言できます。</p>
 
-<p>Likewise, a subroutine call <tt>Baz::Qux::processThis()</tt> need not necessarily have been declared inside a file named <tt>Baz/Qux.pm</tt>. It could have been declared <em>literally anywhere</em>.</p>
-<p>Separating these two concepts is one of the stupidest features of Perl, and treating them as separate concepts invariably results in chaotic, maddening code. Fortunately for us, the majority of Perl programmers obey the following two laws:</p>
-<ol>
+<p class=original>Likewise, a subroutine call <tt>Baz::Qux::processThis()</tt> need not necessarily have been declared inside a file named <tt>Baz/Qux.pm</tt>. It could have been declared <em>literally anywhere</em>.</p>
+<p>その上、<tt>Baz::Qux::processThis()</tt>のサブルーチン呼び出しは、<tt>Baz/Qux.pm</tt>という名前のファイル内に宣言されている必要すらありません。<em>文字通り、どこにでも</em>定義することができます。</p>
+<p class=original>Separating these two concepts is one of the stupidest features of Perl, and treating them as separate concepts invariably results in chaotic, maddening code. Fortunately for us, the majority of Perl programmers obey the following two laws:</p>
+<p>この2つのコンセプトを分けてしまったことは、Perlの最も愚かな特徴の1つであり、これら2つのコンセプトを分けて取り扱ってしまうと常に、カオスで気の狂ったようなコードとなります。幸運なことに、Perlプログラマの多くは、次の2つの規則に従っています:</p>
+<ol class="original">
 	<li><strong>A Perl script (<tt>.pl</tt> file) must always contain exactly zero <tt>package</tt> declarations.</strong></li>
 	<li><strong>A Perl module (<tt>.pm</tt> file) must always contain exactly one <tt>package</tt> declaration, corresponding exactly to its name and location.</strong> E.g. module <tt>Mathematics/Powers.pm</tt> must begin with <tt>package Mathematics::Powers</tt>.</li>
 </ol>
-<p>Because of this, in practice you will find that most "packages" and "modules" produced by reliable third parties <em>can</em> be regarded and referred to interchangeably. However, it is important that you do not take this for granted, because one day you <em>will</em> meet code produced by a madman.</p>
+<ol>
+	<li><strong>Perlスクリプト(<tt>.pl</tt>ファイル)は、1つの<tt>package</tt>宣言も含まない。</strong></li>
+	<li><strong>Perlモジュール(<tt>.pm</tt>ファイル)は、1つの<tt>package</tt>宣言を含み、名前と場所が一致している。</strong> 例: モジュール<tt>Mathematics/Powers.pm</tt>は、<tt>package Mathematics::Powers</tt>で始まっている。</li>
+</ol>
 
-<h2>Object-oriented Perl</h2>
+<p class="original">Because of this, in practice you will find that most "packages" and "modules" produced by reliable third parties <em>can</em> be regarded and referred to interchangeably. However, it is important that you do not take this for granted, because one day you <em>will</em> meet code produced by a madman.</p>
+<p>これにより, 信頼できるサードパーティに作られた、ほとんどの"packages"と"modules"を見つけることができ、相互に関係し参照され<em>うる</em>。しかし、これが当たり前と思わないことは重要です。いつか、常軌を逸した人が作ったコードに出会う<em>でしょう</em>。</p>
 
-<p>Perl is not a great language for OO programming. Perl's OO capabilities were grafted on after the fact, and this shows.</p>
+<h2 class="oritingal">Object-oriented Perl</h2>
+<h2>オブジェクト指向Perl</h2>
 
-<ul>
+<p class="orginal">Perl is not a great language for OO programming. Perl's OO capabilities were grafted on after the fact, and this shows.</p>
+<p>PerlはOOプログラミングに、あまり適した言語ではありません。 PerlのOO能力は後付のものです。それは、</p>
+
+<ul class="original">
 	<li><p>An <i>object</i> is simply a reference (i.e. a scalar variable) which happens to know which class its referent belongs to. To tell a reference that its referent belongs to a class, use <tt>bless</tt>. To find out what class a reference's referent belongs to (if any), use <tt>ref</tt>.</p></li>
 	<li><p>A <i>method</i> is simply a subroutine that expects an object (or, in the case of class methods, a package name) as its first argument. Object methods are invoked using <tt>$obj-&gt;method()</tt>; class methods are invoked using <tt>Package::Name-&gt;method()</tt>.</p></li>
 	<li><p>A <i>class</i> is simply a package that happens to contain methods.</p></li>
 </ul>
+<ul>
+	<li><p><i>オブジェクト</i>は単純に、どのクラスに属しているかを示しているリファレンスです(i.e. スカラ変数)。そのリファレントがクラスに属していることをリファレンスに教えるために、<tt>bless</tt>を使います。blessにより、どのクラスがどのリファレントに属するのかを分かるようになります。リファレンスのリファレントがどのクラスに属しているかをみつけるためには、<tt>ref</tt>を使います</p></li></li>
+	<li><p><i>メソッド</i>は単純に第一引数オブジェクト(または、クラスメソッドであれば、パッケージ名)であるサブルーチンです。オブジェクトメソッドは、<tt>$obj-&gt;method()</tt>を使って呼び出されます; クラスメソッドは<tt>Package::Name-&gt;method()</tt>です。</p></li>
+	<li><p><i>クラス</i>は単純にメソッドを含むパッケージです。</p></li>
+</ul>
 
-<p>A quick example. An example module <tt>Animals/Animals.pm</tt> containing a class <tt>Animals::Animal</tt> reads like this:</p>
+<p class="original">A quick example. An example module <tt>Animals/Animals.pm</tt> containing a class <tt>Animals::Animal</tt> reads like this:</p>
+<p>以下、簡単な例です。 例として、<tt>Animals::Animal</tt>クラスを含むモジュール<tt>Animals/Animals.pm</tt>は、次のようになります:</p>
 
 <pre class="perl prettyprint">
 use strict;
@@ -1487,7 +1505,8 @@
 1;
 </pre>
 
-<p>And a Perl script making use of this class might read:</p>
+<p class="original">And a Perl script making use of this class might read:</p>
+<p>このクラスを使うPerlスクリプトは次のようになるでしょう:</p>
 
 <pre class="perl prettyprint">
 use strict;
@@ -1503,13 +1522,17 @@
 $animal-&gt;eat("insects", "curry", "salmon");
 </pre>
 
-<p>This final call is equivalent to <tt>Animals::Animal::eat($animal, "insects", "curry", "salmon")</tt>.</p>
+<p class="original">This final call is equivalent to <tt>Animals::Animal::eat($animal, "insects", "curry", "salmon")</tt>.</p>
+<p>最後の呼び出しは、<tt>Animals::Animal::eat($animal, "insects", "curry", "salmon")</tt>と同じです。</p>
 
-<p>Note: literally any reference can be blessed into any class. It's up to you to ensure that (1) the referent can actually be used as an instance of this class and (2) that the class in question exists and has been loaded.</p>
+<p class="original">Note: literally any reference can be blessed into any class. It's up to you to ensure that (1) the referent can actually be used as an instance of this class and (2) that the class in question exists and has been loaded.</p>
+<p>注意: 文字通り、どのようなリファレンスも、どのようなクラスにでもblessされえます。(1)リファレンスが実際にそのクラスのインスタンスとして使われているかと、(2)問題のクラスが存在し、ロードされているかを保証するのはあなた次第です。</p>
 
-<h3>Inheritance</h3>
+<h3 class="original">Inheritance</h3>
+<h3>継承</h3>
 
-<p>To create a class inheriting from a base class, populate the <tt>@ISA</tt> package variable. Let's suppose we subclassed <tt>Animals::Animal</tt> with <tt>Animals::Bear</tt>, located at <tt>Animals/Bear.pm</tt>:</p>
+<p class="original">To create a class inheriting from a base class, populate the <tt>@ISA</tt> package variable. Let's suppose we subclassed <tt>Animals::Animal</tt> with <tt>Animals::Bear</tt>, located at <tt>Animals/Bear.pm</tt>:</p>
+<p>ベースクラスから継承しているクラスを作るには、<tt>@ISA</tt>パッケージ変数にベースクラスを入れます。サブクラス<tt>Animals::Animal</tt>を<tt>Animals::Bear</tt>でサブクラスを作るとします。場所は<tt>Animals/Bear.pm</tt>になります:</p>
 
 <pre class="perl prettyprint">
 use strict;
@@ -1532,7 +1555,8 @@
 1;
 </pre>
 
-<p>And some sample code:</p>
+<p class="original">And some sample code:</p>
+<p>サンプルコード:</p>
 
 <pre class="perl prettyprint">
 use strict;
@@ -1545,12 +1569,18 @@
 $bear-&gt;eat("insects", "curry", "salmon"); # eat only the salmon
 </pre>
 
-<p>This final method call tries to invoke <tt>Animals::Bear::eat($bear, "insects", "curry", "salmon")</tt>, but a subroutine <tt>eat()</tt> isn't defined in the <tt>Animals::Bear</tt> package. However, because <tt>@ISA</tt> has been populated with a parent package <tt>Animals::Animal</tt>, the Perl interpreter tries calling <tt>Animals::Animal::eat($bear, "insects", "curry", "salmon")</tt> instead, which works. Note how the class <tt>Animals::Animal</tt> had to be loaded explicitly by <tt>Animals::Bear</tt>.</p>
-<p>Since <tt>@ISA</tt> is an array, Perl supports multiple inheritance, with all the benefits and horrors this entails.</p>
+<p class="original">This final method call tries to invoke <tt>Animals::Bear::eat($bear, "insects", "curry", "salmon")</tt>, but a subroutine <tt>eat()</tt> isn't defined in the <tt>Animals::Bear</tt> package. However, because <tt>@ISA</tt> has been populated with a parent package <tt>Animals::Animal</tt>, the Perl interpreter tries calling <tt>Animals::Animal::eat($bear, "insects", "curry", "salmon")</tt> instead, which works. Note how the class <tt>Animals::Animal</tt> had to be loaded explicitly by <tt>Animals::Bear</tt>.</p>
+<p>最後のメソッド呼び出しは、<tt>Animals::Bear::eat($bear, "insects", "curry", "salmon")</tt>を呼ぼうとしますが、サブルーチン<tt>eat()</tt>は、<tt>Animals::Bear</tt> パッケージには定義されていません。ですが、<tt>@ISA</tt>にパッケージ<tt>Animals::Animal</tt>があるので、Perlインタプリタは <tt>Animals::Animal::eat($bear, "insects", "curry", "salmon")</tt>を代わりに呼ぼうとして、代わりにそれは動きます。次のことに注意してください。クラス<tt>Animals::Animal</tt>は<tt>Animals::Bear</tt>で明示的にロードされていなければいけません。</p>
+<p class="original">Since <tt>@ISA</tt> is an array, Perl supports multiple inheritance, with all the benefits and horrors this entails.</p>
+<p><tt>@ISA</tt> は配列なので、Perl は多重継承をサポートします。全ての利益と恐怖を伴いますが。</p>
+
 
-<h2><tt>BEGIN</tt> blocks</h2>
+<h2 class="original"><tt>BEGIN</tt> blocks</h2>
+<h2><tt>BEGIN</tt>ブロック</h2>
 
-<p>A <tt>BEGIN</tt> block is executed as soon as the compiler has finished parsing it, even before the compiler parses the rest of the file. It is ignored at execution time.</p>
+<p class="original">A <tt>BEGIN</tt> block is executed as soon as the compiler has finished parsing it, even before the compiler parses the rest of the file. It is ignored at execution time.</p>
+
+<p><tt>BEGIN</tt>ブロックはコンパイラがそのブロックをパースし終えるとすぐに実行されます。コンパイラがまだ全てをパースしていなくてもです。BEGINブロックは実行時には無視されます。</p>
 
 <pre class="perl prettyprint">
 use strict;
@@ -1565,8 +1595,11 @@
 # actual code
 </pre>
 
-<p>A <tt>BEGIN</tt> block is always executed first. If you create multiple <tt>BEGIN</tt> blocks (don't), they are executed in order from top to bottom as the compiler encounters them. A <tt>BEGIN</tt> block always executes first even if it is placed halfway through a script (don't do this) or even at the end (or this).</p>
-<p>Because they are executed at compilation time, a <tt>BEGIN</tt> block placed inside a conditional block will <em>still</em> be executed first, even if the conditional evaluates to false and despite the fact that the conditional <em>has not been evaluated at all yet</em> and in fact <em>may never be evaluated</em>. <strong>Do not put <tt>BEGIN</tt> blocks in conditionals!</strong> If you want to do something conditionally at compile time, you need to put the conditional <em>inside</em> the <tt>BEGIN</tt> block:</p>
+<p class="original">A <tt>BEGIN</tt> block is always executed first. If you create multiple <tt>BEGIN</tt> blocks (don't), they are executed in order from top to bottom as the compiler encounters them. A <tt>BEGIN</tt> block always executes first even if it is placed halfway through a script (don't do this) or even at the end (or this).</p>
+<p><tt>BEGIN</tt>ブロックは常にさいs鬼実行されます。複数の<tt>BEGIN</tt>ブロックを書くと(don't)、 上から順番にコンパイラがそれらに出会う順番に実行されます。<tt>BEGIN</tt>ブロックは常に最初に実行されます。もし、BEGINブロックがスクリプトの途中(そんなことはしないでください)や、最後(or this)に書かれていたりしてさえも。</p>
+<p class="original">Because they are executed at compilation time, a <tt>BEGIN</tt> block placed inside a conditional block will <em>still</em> be executed first, even if the conditional evaluates to false and despite the fact that the conditional <em>has not been evaluated at all yet</em> and in fact <em>may never be evaluated</em>. <strong>Do not put <tt>BEGIN</tt> blocks in conditionals!</strong> If you want to do something conditionally at compile time, you need to put the conditional <em>inside</em> the <tt>BEGIN</tt> block:</p>
+<p>コンパイル時に実行されるので、<tt>BEGIN</tt>ブロックが条件ブロックの中にあっても、<em>まだ</em>最初に実行されます。たとえ、条件の評価が偽であり、条件が<em>まだまったく評価されていない</em>にもかかわらず、実際には、<em>評価されることがない</em>としてもです。
+<strong><tt>BEGIN</tt>ブロックを条件の中に置いては行けません!</strong> コンパイル時に何かしらの条件付きのことがしたければ、<tt>BEGIN</tt>ブロックの<em>中に<em>条件文を置かなければなりません:</p>
 <pre class="perl prettyprint">
 BEGIN {
 	if($condition) {
@@ -1576,14 +1609,17 @@
 </pre>
 
 <h2><tt>use</tt></h2>
-<p>Okay. Now that you understand the obtuse behaviour and semantics of packages, modules, class methods and <tt>BEGIN</tt> blocks, I can explain the exceedingly commonly-seen <tt>use</tt> function.</p>
-<p>The following three statements:</p>
+<p class="original">Okay. Now that you understand the obtuse behaviour and semantics of packages, modules, class methods and <tt>BEGIN</tt> blocks, I can explain the exceedingly commonly-seen <tt>use</tt> function.</p>
+<p>いいでしょう。もうわかりにくい、パッケージ、モジュールクラスメソッドと<tt>BEGIN</tt>ブロックの意味を理解したので、よく見かける<tt>use</tt>関数について説明できます。</p>
+<p class="original">The following three statements:</p>
+<p>以下の3つのステートメントは:</p>
 <pre class="perl prettyprint">
 use Bugs::Caterpillar ("crawl", "pupate");
 use Bugs::Caterpillar ();
 use Bugs::Caterpillar;
 </pre>
-<p>are respectively equivalent to:</p>
+<p class="original">are respectively equivalent to:</p>
+<p>以下とそれぞれ等価です:</p>
 <pre class="perl prettyprint">
 BEGIN {
 	require Bugs::Caterpillar;
@@ -1597,18 +1633,27 @@
 	Bugs::Caterpillar-&gt;import();
 }
 </pre>
-<ul>
+<ul class="original">
 	<li>No, the three examples are not in the wrong order. It is just that Perl is dumb.</li>
 	<li>A <tt>use</tt> call is a disguised <tt>BEGIN</tt> block. The same caveats apply. <tt>use</tt> statements must always be placed at the top of the file, and <strong>never inside conditionals</strong>.</li>
 	<li><tt>import()</tt> is not a built-in Perl function. It is a <strong>user-defined class method</strong>. The burden is on the programmer of the <tt>Bugs::Caterpillar</tt> package to define or inherit <tt>import()</tt>, and the method could theoretically accept anything as arguments and do anything with those arguments.</li>
 	<li>Notice how <tt>require Bugs::Caterpillar</tt> loads a <strong>module</strong> named <tt>Bugs/Caterpillar.pm</tt>, whereas <tt>Bugs::Caterpillar-&gt;import()</tt> calls the <tt>import()</tt> subroutine that was defined inside the <tt>Bugs::Caterpillar</tt> <strong>package</strong>. Let's hope the module and the package coincide!</li>
 </ul>
 
+<ul>
+	<li>いいえ、3つの例は間違った順番ではありません。Perlが馬鹿なだけです。</li>
+	<li><tt>use</tt>の呼び出しは<tt>BEGIN</tt>ブロックに変換されます。同じ警告が適用されます。<tt>use</tt>ステートメントはファイルの最初に置かれなければいけません。<strong>条件の中に置いてはいけません</strong>。</li>
+	<li><tt>import()</tt> はPerlの組込の関数ではありません。<strong>ユーザー定義のクラスメソッドです</strong>。<tt>import()</tt>を定義するか、継承するかの義務は<tt>Bugs::Caterpillar</tt>パッケージのプログラマにあり、メソッドは理論上、どのような引数でも受け入れ、どのようなことでもできます。</li>
+	<li><tt>require Bugs::Caterpillar</tt>が<tt>Bugs/Caterpillar.pm</tt>という名前の<strong>module</strong>をロードすることに注意してください。<tt>Bugs::Caterpillar-&gt;import()</tt>は、<tt>Bugs::Caterpillar</tt> <strong>package</strong>内に定義された<tt>import()</tt>サブルーチンを呼びます。モジュールとパッケージが一致していることを期待しましょう!</li>
+</ul>
+
 <h2>Exporter</h2>
 
-<p>The most common way to define an <tt>import()</tt> method is to inherit it from Exporter module. Exporter is a <i>de facto</i> core feature of the Perl programming language. In Exporter's implementation of <tt>import()</tt>, the list of arguments that you pass in is interpreted as a list of subroutine names. When a subroutine is <tt>import()</tt>ed, it becomes available in the current namespace as well as in its own original namespace.</p>
+<p class="original">The most common way to define an <tt>import()</tt> method is to inherit it from Exporter module. Exporter is a <i>de facto</i> core feature of the Perl programming language. In Exporter's implementation of <tt>import()</tt>, the list of arguments that you pass in is interpreted as a list of subroutine names. When a subroutine is <tt>import()</tt>ed, it becomes available in the current namespace as well as in its own original namespace.</p>
 
-<p>This concept is easiest to grasp using an example. Here's what <tt>Bugs/Caterpillar.pm</tt> looks like:</p>
+<p><tt>import()</tt>メソッドを定義する常識的な方法は Exporter モジュールから継承することです。Exporter はプログラミング言語Perlの<i>デファクト</i>のコアの機能です。Exporterの<tt>import</tt>の実装で、渡した引数のリストは、サブルーチンの名前として解釈されます。サブルーチンが<tt>import()</tt>されると、現在の名前空間で、そのオリジナルの名前空間にあるかのと同じように、利用可能になります。</p>
+<p class="original">This concept is easiest to grasp using an example. Here's what <tt>Bugs/Caterpillar.pm</tt> looks like:</p>
+<p>このコンセプトは例を使うと把握しやすいでしょう。<tt>Bugs/Caterpillar.pm</tt>は次のようなものです:</p>
 
 <pre class="perl prettyprint">
 use strict;
@@ -1630,7 +1675,8 @@
 1;
 </pre>
 
-<p>And here's a script which makes use of the <tt>Bugs/Caterpillar.pm</tt> module:</p>
+<p class="original">And here's a script which makes use of the <tt>Bugs/Caterpillar.pm</tt> module:</p>
+<p><tt>Bugs/Caterpillar.pm</tt>モジュールを使ったスクリプトです:</p>
 
 <pre class="perl prettyprint">
 use strict;



perldocjp-cvs メーリングリストの案内
Back to archive index