ktats****@users*****
ktats****@users*****
2012年 9月 8日 (土) 22:19:31 JST
Index: docs/articles/qntm.org/files/perl/perl.html diff -u docs/articles/qntm.org/files/perl/perl.html:1.12 docs/articles/qntm.org/files/perl/perl.html:1.13 --- docs/articles/qntm.org/files/perl/perl.html:1.12 Mon Sep 3 00:32:56 2012 +++ docs/articles/qntm.org/files/perl/perl.html Sat Sep 8 22:19:30 2012 @@ -1,4 +1,4 @@ -r<!Doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<!Doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> @@ -28,11 +28,11 @@ <p>Perlã¯åçãªãåçåä»ãã®ãé«ç´ãªãã¹ã¯ãªãã(ã¤ã³ã¿ã¼ããªã¿ã§è§£éããã)è¨èªã§ãPHPãPythonã¨ã¨ãã«ããæ¯è¼ããã¾ããPerlã®ã·ã³ã¿ãã¯ã¹ã¯ãæã®shellã¹ã¯ãªãããã¼ã«ããå¤ãã®é¨åãåãã¦ãããããã«ããæ··ä¹±ãããã·ã³ãã«ã使ãéãã¦ãããã¨ã§æåã§ãããããã®å¤§å¤æ°ãGoogleã§æ¤ç´¢ãããã¨ã¯ä¸å¯è½ã§ããPerlã®shellã¹ã¯ãªããããåãç¶ãã éºç£ã¯ã<i>glueã³ã¼ã</i>(ä»ã®ã¹ã¯ãªãããããã°ã©ã ã¨ä¸ç·ã«ãªã³ã¯ããã¦ããã¹ã¯ãªãã)ãæ¸ãã®ã«ã大å¤å½¹ã«ç«ã¡ã¾ããPerlã¯ãçæ³çã«ããã¹ããã¼ã¿ãå¦çãããã¨ããããã¹ããã¼ã¿ãçæããã®ã«é©ãã¦ãã¾ããPerlã¯åºãè¡ã渡ããæåã§ããã極ãã¦ãã¼ã¿ãã«ã§ãååã«ãµãã¼ãããã¦ãã¾ããPerlã¯"There's More Than One Way To Do It(ããæ¹ã¯ã²ã¨ã¤ãããªã) " (TMTOWTDI)ã®å²å¦ã§ãã¶ã¤ã³ããã¾ãã(Pythonã¨æ¯è¼ããã¨ã"there should be one - and preferably only one - obvious way to do it(æãããªããæ¹ã¯ãã²ã¨ã¤ã§ããã¹ãã§ããããããã²ã¨ã¤ã®ã¿ã§ããã¹ã)")ã</p> -<p class=original>Perl has horrors, but it also has some great redeeming features. In this respect it is like every other programming language ever created.</p> +<p class="original">Perl has horrors, but it also has some great redeeming features. In this respect it is like every other programming language ever created.</p> <p>Perlã«ã¯æãããã¨ãããããã¾ããããããè£ã£ã¦ä½ãããè¯ããããã¾ãããã®ç¹ã§ãä»ã¾ã§ã«ä½ãããå ¨ã¦ã®ä»ã®ããã°ã©ãã³ã°è¨èªã¨åãã§ãã</p> -<p class=original>This document is intended to be informative, not evangelical. It is aimed at people who, like me:</p> +<p class="original">This document is intended to be informative, not evangelical. It is aimed at people who, like me:</p> <p>ãã®ããã¥ã¡ã³ãã¯ãæ å ±ãä¸ãããã¨ãæå³ãã¦ãããç±å¿ã«æ®åããããã®ã§ã¯ããã¾ããã以ä¸ã®ãããªãç§ã®ãããªäººåãã®ãã®ã§ã:</p> -<ul class=original> +<ul class="original"> <li>dislike the official Perl documentation at <a href="http://perl.org">http://perl.org/</a> for being intensely technical and giving far too much space to very unusual edge cases</li> <li>learn new programming languages most quickly by "axiom and example"</li> <li>wish Larry Wall would get to the point</li> @@ -48,13 +48,13 @@ <li>ä»äºãçµããããã«ä½ãå¿ è¦ãã¨ãããã¨ä»¥ä¸ã®ãã¨ãPerlã«ã¤ãã¦æ°ã«ããªã</li> </ul> -<p class=original>This document is intended to be as short as possible, but no shorter.</p> +<p class="original">This document is intended to be as short as possible, but no shorter.</p> <p>ãã®ããã¥ã¡ã³ãã¯å¯è½ãªéãçããã¦ãã¾ããã足ããªããã¨ã®ãªãããã«ãã¦ãã¾ãã</p> -<h2 class=original>Preliminary notes</h2> +<h2 class="original">Preliminary notes</h2> <h2>åæ¸ã</h2> -<ul class=original> +<ul class="original"> <li><p class="original">The following can be said of almost every declarative statement in this document: "that's not, strictly speaking, true; the situation is actually a lot more complicated". If you see a serious lie, point it out, but I reserve the right to preserve certain critical lies-to-children.</p> <p>以ä¸ã®ãã¨ãããã®ããã¥ã¡ã³ãå ã®ã»ã¨ãã©ãã¹ã¦ã®å®£è¨æã§è¨ããã¨ãåºæ¥ã¾ã: "ããã¯ãå³æ ¼ãªæå³ã§ã®ãçå®ã§ã¯ããã¾ãã; ç¶æ³ã¯å®éã«ã¯ãã£ã¨è¤éã§ã"ãããæ·±å»ãªåãè¦ã¤ããããææãã¦ãã ãããã§ãããç§ã«ã¯åã©ãã«ã¤ãéè¦ãªåããã®ã¾ã¾ã«ãã¦ãã権å©ãããã¾ãã</p></li> <li><p class="original">Throughout this document I'm using example <code>print</code> statements to output data but not explicitly appending line breaks. This is done to prevent me from going crazy and to give greater attention to the actual string being printed in each case, which is invariably more important. In many examples, this results in alotofwordsallsmusheduptogetherononeline if the code is run in reality. Try to ignore this. </p> @@ -65,9 +65,9 @@ <h2>Hello world</h2> -<p class=original>A Perl <i>script</i> is a text file with the extension <code>.pl</code>.</p> +<p class="original">A Perl <i>script</i> is a text file with the extension <code>.pl</code>.</p> <p>Perl<i>ã¹ã¯ãªãã</i>ã¯<code>.pl</code>ã¨ããæ¡å¼µåã®ããã¹ããã¡ã¤ã«ã§ãã</p> -<p class=original>Here's the full text of <code>helloworld.pl</code>:</p> +<p class="original">Here's the full text of <code>helloworld.pl</code>:</p> <p><code>helloworld.pl</code>ã¯ä»¥ä¸ã®ããã«ãªãã¾ã:</p> <pre class="perl prettyprint"> use strict; @@ -75,13 +75,13 @@ print "Hello world"; </pre> -<p class=original>Perl scripts are interpreted by the Perl interpreter, <code>perl</code> or <code>perl.exe</code>:</p> +<p class="original">Perl scripts are interpreted by the Perl interpreter, <code>perl</code> or <code>perl.exe</code>:</p> <p>Perlã¹ã¯ãªããã¯Perlã¤ã³ã¿ã¼ããªã¿ã<code>perl</code>ã<code>perl.exe</code>ã§è§£éããã¾ã:</p> <pre class="bash"> perl helloworld.pl [arg0 [arg1 [arg2 ...]]] </pre> -<p class=original>A few immediate notes. Perl's syntax is highly permissive and it will allow you to do things which result in ambiguous-looking statements with unpredictable behaviour. There's no point in me explaining what these behaviours are, because you want to avoid them. The way to avoid them is to put <code>use strict; use warnings;</code> at the very top of every Perl script or module that you create. Statements of the form <code>use foo;</code> are <i>pragmas</i>. A pragma is a signal to <code>perl.exe</code>, which takes effect when initial syntactic validation is being performed, before the program starts running. These lines have no effect when the interpreter encounters them at run time.</p> +<p class="original">A few immediate notes. Perl's syntax is highly permissive and it will allow you to do things which result in ambiguous-looking statements with unpredictable behaviour. There's no point in me explaining what these behaviours are, because you want to avoid them. The way to avoid them is to put <code>use strict; use warnings;</code> at the very top of every Perl script or module that you create. Statements of the form <code>use foo;</code> are <i>pragmas</i>. A pragma is a signal to <code>perl.exe</code>, which takes effect when initial syntactic validation is being performed, before the program starts running. These lines have no effect when the interpreter encounters them at run time.</p> <p>å½é¢ã®ã¡ã¢ã¨ãã¦ããã¤ããPerlã®ã·ã³ã¿ãã¯ã¹ã¯ããªãå¯å¤§ãªã®ã§ãçµæã¨ãã¦æ¯ãèããäºæ¸¬ã§ããªãææ§ã«è¦ãããããªã»ã³ãã³ã¹ãæ¸ããã¨ãããªãã«è¨±ãã¾ããç§ã«ã¨ã£ã¦ã¯æå³ããªãã®ã§ããããã®æ¯ãèãã«é¢ãã¦èª¬æãã¾ããããªããªããããªãã¯ããããé¿ãããã§ããããããããããé¿ããæ¹æ³ã¯ã<code>use strict;use warnings;</code>ããããªãã®ä½ãå ¨ã¦ã®perlã¹ã¯ãªãããã¢ã¸ã¥ã¼ã«ã®ä¸ã®æ¹ã«ç½®ããã¨ã§ãã<code>use</code> fooã®ã¹ãã¼ãã¡ã³ãã¯<i>ãã©ã°ã</i>ã§ãããã©ã°ãã¯<code>Perl.exe</code>ã¸ã®ã·ã°ãã«ã§ããããã°ã©ã ãèµ°ãå§ããåã«ãæåã®ã·ã³ã¿ãã¯ã¹ãã§ãã¯ãããæ¹æ³ãå¤æ´ãã¾ãããããã®è¡ã¯ã³ã³ãã¤ã«æã«å½±é¿ããå®è¡æã«ã¯ã¤ã³ã¿ã¼ããªã¿ãåºãããã¦ãå½±é¿ãåãã¾ããã</p> <p class="original">The symbol <code>#</code> begins a comment. A comment lasts until the end of the line. Perl has no block comment syntax.</p> @@ -91,17 +91,17 @@ <h2>å¤æ°</h2> -<p class=original>Perl variables come in three types: <i>scalars</i>, <i>arrays</i> and <i>hashes</i>. Each type has its own <i>sigil</i>: <code>$</code>, <code>@</code> and <code>%</code> respectively. Variables are declared using <code>my</code>, and remain in scope until the end of the enclosing block or file.</p> +<p class="original">Perl variables come in three types: <i>scalars</i>, <i>arrays</i> and <i>hashes</i>. Each type has its own <i>sigil</i>: <code>$</code>, <code>@</code> and <code>%</code> respectively. Variables are declared using <code>my</code>, and remain in scope until the end of the enclosing block or file.</p> <p>Perlã®å¤æ°ã«ã¯æ¬¡ã®3ã¿ã¤ãããã¾ã: <i>ã¹ã«ã©</i>ã<i>é å</i>ã <i>ããã·ã¥</i>ã§ã. ããããã®ã¿ã¤ãã«ã¯ãèªèº«ã®<i>ã·ã¸ã«(sigil)</i>ãããã¾ã: ããããã<code>$</code>, <code>@</code> and <code>%</code>ã å¤æ°ã¯<code>my</code>ã§å®£è¨ããããããã¯ãï½ã¤ã«ã®æå¾ã¾ã§ã¹ã³ã¼ãå ã«æ®ãã¾ãã</p> -<h3 class=original>Scalar variables</h3> +<h3 class="original">Scalar variables</h3> <h3>ã¹ã«ã©å¤æ°</h3> -<p class=original>A scalar variable can contain:</p> +<p class="original">A scalar variable can contain:</p> <p>ã¹ã«ã©å¤æ°ã¯ä»¥ä¸ã®ãã®ãæ ¼ç´ã§ãã¾ã:</p> -<ul class=original> +<ul class="original"> <li><code>undef</code> (corresponds to <code>None</code> in Python, <code>null</code> in PHP)</li> <li>a number (Perl does not distinguish between an integer and a float)</li> <li>a string</li> @@ -133,10 +133,10 @@ print $string; # "world" </pre> -<p class=original>(References are coming up shortly.)</p> +<p class="original">(References are coming up shortly.)</p> <p>(ãªãã¡ã¬ã³ã¹ã¯å¾ã§èª¬æãã¾ã)</p> -<p class=original>String concatenation using the <code>.</code> operator (same as PHP):</p> +<p class="original">String concatenation using the <code>.</code> operator (same as PHP):</p> <p>æååã®é£çµã«ã¯<code>.</code>æ¼ç®åã使ãã¾ã(PHPã¨åã):</p> <pre class="perl prettyprint"> print "Hello ".$string; # "Hello world" @@ -144,7 +144,7 @@ <h3 class="original">"Booleans"</h3> <h3>çå½å¤</h3> -<p class=original><strong>Perl has no boolean data type.</strong> A scalar in an <code>if</code> statement evaluates to boolean "false" if and only if it is one of the following:</p> +<p class="original"><strong>Perl has no boolean data type.</strong> A scalar in an <code>if</code> statement evaluates to boolean "false" if and only if it is one of the following:</p> <p><strong>Perlã«ã¯ãã¼ãªã¢ã³ã®ãã¼ã¿åã¯ããã¾ããã</strong> <code>if</code>ã¹ãã¼ãã¡ã³ãã§ã¯ã¹ã«ã©ã¯ã以ä¸ã®ããããã®å ´åã«ã®ã¿"å½"ã¨ãã¦è©ä¾¡ããã¾ã:</p> @@ -155,13 +155,13 @@ <li>string <code>"0"</code>.</li> </ul> -<p class=original>The Perl documentation <em>repeatedly</em> claims that functions return "true" or "false" values in certain situations. In practice, when a function is claimed to return "true" it usually returns <code>1</code>, and when it is claimed to return false it usually returns the empty string, <code>""</code>.</p> +<p class="original">The Perl documentation <em>repeatedly</em> claims that functions return "true" or "false" values in certain situations. In practice, when a function is claimed to return "true" it usually returns <code>1</code>, and when it is claimed to return false it usually returns the empty string, <code>""</code>.</p> <p>Perlã®ããã¥ã¡ã³ãã§ã¯ã<em>ç¹°ãè¿ã</em>ãç¹å®ã®ç¶æ³ã§"ç"ã"å½"ã®å¤ãé¢æ°ãè¿ãããã«ä¸»å¼µãã¦ãã¾ããå®éã«ã¯ãé¢æ°ãçãè¿ãããã«ä¸»å¼µãã¦ããã¨ãã¯ãæ®é<code>1</code>ãè¿ãã¾ããã¾ããé¢æ°ãå½ãè¿ãããã«ä¸»å¼µãã¦ãããªããæ®éã¯ç©ºæå<code>""</code>ãè¿ãã¾ãã</p> -<h3 class=original>Weak typing</h3> +<h3 class="original">Weak typing</h3> <h3>å¼±ãåä»ã</h3> -<p class=original><strong>It is impossible to determine whether a scalar contains a "number" or a "string".</strong> More precisely, it should never be necessary to do this. Whether a scalar behaves like a number or a string depends on the operator with which it is used. When used as a string, a scalar will behave like a string. When used as a number, a scalar will behave like a number (raising a warning if this isn't possible):</p> +<p class="original"><strong>It is impossible to determine whether a scalar contains a "number" or a "string".</strong> More precisely, it should never be necessary to do this. Whether a scalar behaves like a number or a string depends on the operator with which it is used. When used as a string, a scalar will behave like a string. When used as a number, a scalar will behave like a number (raising a warning if this isn't possible):</p> <p><strong>ã¹ã«ã©ã¼ã«"æ°å"ã"å¤æ°"ã®ãããããå ¥ã£ã¦ããã®ããå¤æãããã¨ã¯ã§ãã¾ããã</strong> ããæ£ç¢ºã«ã¯ããããªãã¨ã¯è¦å½éãã§ããPerlã¯ãã®ç¹ã§å¼±ãåä»ãã§ãã ã¹ã«ã©ãæ°åãæåã®ã©ã¡ããã®ããã«æ¯èããã¯ã使ãããæ¼ç®åã«ããã¾ããæååã¨ãã¦ä½¿ãã°ãã¹ã«ã©ã¯æååã®ããã«ãµãã¾ãã¾ããæ°åã¨ãã¦ä½¿ãã°ãã¹ã«ã©ã¯æ°åã®ããã«ãµãã¾ãã¾ã(ã¾ãããããããã¨ãåºæ¥ãªããã°ãè¦åãçºãã¾ã):</p> <pre class="perl prettyprint"> @@ -176,7 +176,7 @@ # The classic error print "yes" == "no"; # "1" with two warnings; both values evaluate to 0 when used as numbers </pre> -<p class=original>The lesson is to always using the correct operator in the correct situation. There are separate operators for comparing scalars as numbers and comparing scalars as strings:</p> +<p class="original">The lesson is to always using the correct operator in the correct situation. There are separate operators for comparing scalars as numbers and comparing scalars as strings:</p> <p>ãã®ã¬ãã¹ã³ã§ã¯ãæ£ããç¶æ³ã§æ£ããæ¼ç®åã使ãããã«ãã¦ãã¾ããæ°åã¨ãã¦ã¹ã«ã©ãæ¯è¼ããã®ã¨ãæååã¨ãã¦ã¹ã«ã©ãæ¯è¼ããã®ã¨ã§ã¯ãæ¼ç®åãåºå¥ãã¾ãã:</p> <pre class="perl original"> @@ -186,13 +186,13 @@ <pre class="perl prettyprint"> # æ°åç¨ã®æ¼ç®å: <, >, <=, >=, ==, !=, <=> -# æåç¨ã®æ¼ç®å: <a href="http://perldoc.perl.org/perlop.html#Equality-Operators">lt, gt, le, ge, eq, ne, cmp</a>, <a href="http://perldoc.perl.org/perlop.html#Multiplicative-Operators">.</a>, <a href="http://perldoc.perl.org/perlop.html#Multiplicative-Operators">x</a> +# æåç¨ã®æ¼ç®å: <a href="http://perldoc.jp/docs/perl/perlop.pod#Equality32Operators">lt, gt, le, ge, eq, ne, cmp</a>, <a href="http://perldoc.jp/docs/perl/perlop.pod#Multiplicative32Operators">.</a>, <a href="http://perldoc.jp/docs/perl/perlop.pod#Multiplicative32Operators">x</a> </pre> -<h3 class=original>Array variables</h3> +<h3 class="original">Array variables</h3> <h3>é åå¤æ°</h3> -<p class=original>An array variable is a list of scalars indexed by integers beginning at 0. In Python this is known as a <i>list</i>, and in PHP this is known as an <i>array</i>. An array is declared using a parenthesised list of scalars:</p> +<p class="original">An array variable is a list of scalars indexed by integers beginning at 0. In Python this is known as a <i>list</i>, and in PHP this is known as an <i>array</i>. An array is declared using a parenthesised list of scalars:</p> <p>é åå¤æ°ã¯æ´æ°ã®0ã§å§ã¾ãã¯ãã¾ãã¤ã³ããã¯ã¹ãããã¹ã«ã©ã§ããPythonã§ã¯ã<i>list</i>ã§ãPHPã§ã¯ã<i>array</i>ã§ããé åã¯ä¸¸æ¬å¼§ã使ã£ã¦å®£è¨ããããé åã®ãªã¹ãã§ãã</p> <pre class="perl original"> @@ -217,7 +217,7 @@ ); </pre> -<p class=original>You have to use a dollar sign to access a value from an array, because the value being <em>retrieved</em> is not an array but a scalar:</p> +<p class="original">You have to use a dollar sign to access a value from an array, because the value being <em>retrieved</em> is not an array but a scalar:</p> <p>é åããå¤ã«ã¢ã¯ã»ã¹ããã¨ãã«ã¯ãã«è¨å·ã使ããªããã°ããã¾ããã<em>åããã</em>å¤ã¯é åã§ã¯ãªããã¹ã«ã©ã ããã§ã:</p> @@ -231,7 +231,7 @@ print $array[6]; # raises warning, returns undef, prints "" </pre> -<p class=original>You can use negative indices to retrieve entries starting from the end and working backwards:</p> +<p class="original">You can use negative indices to retrieve entries starting from the end and working backwards:</p> <p>è² ã®ã¤ã³ããã¯ã¹ããå¾ãããå¤ãåãã®ã«ä½¿ãã¾ããéåãã«ãªãã¾ã:</p> <pre class="perl prettyprint"> @@ -244,11 +244,11 @@ print $array[-7]; # raises warning, returns undef, prints "" </pre> -<p class=original>There is no collision between a scalar <code>$var</code> and an array <code>@var</code> containing a scalar entry <code>$var[0]</code>. There may, however, be reader confusion, so avoid this.</p> +<p class="original">There is no collision between a scalar <code>$var</code> and an array <code>@var</code> containing a scalar entry <code>$var[0]</code>. There may, however, be reader confusion, so avoid this.</p> <p>ã¹ã«ã©<code>$array</code>ã¨ã¹ã«ã©ã®ã¨ã³ããª<code>$var[0]</code>ãæã¤é å<code>@var</code>ã¯è¡çªãã¾ããã ã¨ã¯ãããã³ã¼ããèªã人ãæ··ä¹±ãã¾ãã®ã§ãåãååãä»ããã®ã¯é¿ãã¾ãããã</p> -<p class=original>To get an array's length:</p> +<p class="original">To get an array's length:</p> <p>é åã®é·ããå¾ãã«ã¯:</p> <pre class="perl prettyprint"> @@ -256,17 +256,17 @@ print "The last populated index is ".$#array; # "The last populated index is 5" </pre> -<p class=original>The arguments with which the original Perl script was invoked are stored in the <a href="http://perldoc.perl.org/perlvar.html">built-in array variable</a> <code>@ARGV</code>.</p> -<p>ãªãªã¸ãã«ã®Perlã¹ã¯ãªããã®å®è¡æã®å¼æ°ã¯ã<a href="http://perldoc.perl.org/perlvar.html">çµè¾¼ã®é åå¤æ°</a><code>@ARGV</code>ã«å ¥ãã¾ãã</p> +<p class="original">The arguments with which the original Perl script was invoked are stored in the <a href="http://perldoc.perl.org/perlvar.html">built-in array variable</a> <code>@ARGV</code>.</p> +<p>ãªãªã¸ãã«ã®Perlã¹ã¯ãªããã®å®è¡æã®å¼æ°ã¯ã<a href="http://perldoc.jp/docs/perl/perlvar.pod">çµè¾¼ã®é åå¤æ°</a><code>@ARGV</code>ã«å ¥ãã¾ãã</p> -<p class=original>Variables can be interpolated into strings:</p> +<p class="original">Variables can be interpolated into strings:</p> <p>å¤æ°ãæååã®éã«å ¥ãããã¨ãã§ãã¾ã:</p> <pre class="perl prettyprint"> print "Hello $string"; # "Hello world" print "@array"; # "print these strings out for me" </pre> -<p class=original><strong>Caution.</strong> One day you will put somebody's email address inside a string, <code>"jeff****@gmail*****"</code>. This will cause Perl to look for an array variable called <code>@gmail</code> to interpolate into the string, and not find it, resulting in a runtime error. Interpolation can be prevented in two ways: by backslash-escaping the sigil, or by using single quotes instead of double quotes.</p> +<p class="original"><strong>Caution.</strong> One day you will put somebody's email address inside a string, <code>"jeff****@gmail*****"</code>. This will cause Perl to look for an array variable called <code>@gmail</code> to interpolate into the string, and not find it, resulting in a runtime error. Interpolation can be prevented in two ways: by backslash-escaping the sigil, or by using single quotes instead of double quotes.</p> <p><strong>注æã</strong> ããæ¥ã誰ãã®ã¡ã¼ã«ã¢ãã¬ã¹ã<code>"jeff****@gmail*****"</code>ãæååã«å ¥ããã¨ãã¾ãã ããã¯ãPerlã«<code>@gmail</code>ã¨ããé åå¤æ°ãæ¢ãããæååã®éã«å ¥ãããã¨ãã¾ãããããè¦ã¤ãããªããã°ãã¨ã©ã¼ã«ãªãã¾ããå¤æ°ã®å±éãé²ãã«ã¯2ã¤ã®æ¹æ³ãããã¾ã:ã·ã¸ã«ãã¨ã¹ã±ã¼ããããã¾ã¦ãããããã«ã¯ã©ã¼ãã®ä»£ããã«ã·ã³ã°ã«ã¯ã©ã¼ãã使ãã</p> <pre class="perl prettyprint"> @@ -276,10 +276,10 @@ print '@array'; # "@array" </pre> -<h3 class=original>Hash variables</h3> +<h3 class="original">Hash variables</h3> <h3>ããã·ã¥å¤æ°</h3> -<p class=original>A hash variable is a list of scalars indexed by strings. In Python this is known as a <i>dictionary</i>, and in PHP it is known as an <i>array</i>.</p> +<p class="original">A hash variable is a list of scalars indexed by strings. In Python this is known as a <i>dictionary</i>, and in PHP it is known as an <i>array</i>.</p> <p>ããã·ã¥å¤æ°ã¯æåã§ã¤ã³ããã¯ã¹ãããç´ ããã®ãªã¹ãã§ããPythonã§ã¯<i>dictionary</i>ãPHPã§ã¯<i>array</i>ã«ãªãã¾ãã</p> <pre class="perl prettyprint"> @@ -290,10 +290,10 @@ ); </pre> -<p class=original>Notice how similar this declaration is to an array declaration. In fact, the double arrow symbol <code>=></code> is called a "fat comma", because it is just a synonym for the comma separator. A hash is declared using a list with an even number of elements, where the even-numbered elements (0, 2, ...) are all taken as strings.</p> +<p class="original">Notice how similar this declaration is to an array declaration. In fact, the double arrow symbol <code>=></code> is called a "fat comma", because it is just a synonym for the comma separator. A hash is declared using a list with an even number of elements, where the even-numbered elements (0, 2, ...) are all taken as strings.</p> <p>ãã®å®£è¨ã¯é åå¤æ°ã®å®£è¨ã«ã¨ã¦ãä¼¼ã¦ãããã¨ã«æ³¨æãã¦ãã ãããå®éã«ãäºéç¢å°è¨å·<code>=></code>ã¯ã"ãã¡ããã«ã³ã"ã¨å¼ã°ãã¾ããã¨ããã®ããããã¯ãã«ã³ãã»ãã¬ã¼ã¿ã®ã¾ãã«ã·ããã ã ããã§ããããã·ã¥ã¯å¶æ°ã®æ°ã®ãªã¹ãã使ã£ã¦å®£è¨ããã¾ããå¶æ°ã®è¦ç´ (0, 2, ...)ã¯å ¨ã¦æååã¨ãã¦åããã¾ãã</p> -<p class=original>Once again, you have to use a dollar sign to access a value from a hash, because the value being <em>retrieved</em> is not a hash but a scalar:</p> +<p class="original">Once again, you have to use a dollar sign to access a value from a hash, because the value being <em>retrieved</em> is not a hash but a scalar:</p> <p>ã¾ãã¾ããããã·ã¥ããå¤ã«ã¢ã¯ã»ã¹ããã«ã¯ããã«è¨å·ã使ããªããã°ããã¾ããã<em>åããã</em>å¤ã¯ããã·ã¥ã§ã¯ãªããã¹ã«ã©ã ããã§ã:</p> <pre class="perl original"> @@ -310,18 +310,18 @@ print $scientists{"Dyson"}; # è¦åãèµ·ãã¾ããundefãæ»ãã""ãåºåããã¾ã </pre> -<p class=original>Note the braces used here. Again, there is no collision between a scalar <code>$var</code> and a hash <code>%var</code> containing a scalar entry <code>$var{"foo"}</code>.</p> +<p class="original">Note the braces used here. Again, there is no collision between a scalar <code>$var</code> and a hash <code>%var</code> containing a scalar entry <code>$var{"foo"}</code>.</p> <p>ãã¬ã¼ã¹ã使ããã¦ãããã¨ã«æ³¨æãã¦ãã ãããé åã®ã¨ãã¨åãã§ãããã¹ã«ã©ã®<code>$var</code>ã¨ã¹ã«ã©ã®ã¨ã³ããª<code>$var{"foo"}</code>ãå ¥ã£ã¦ããããã·ã¥ã®<code>%var</code>ã¯è¡çªãã¾ããã</p> -<p class=original>You can convert a hash straight to an array with twice as many entries, alternating between key and value (and the reverse is equally easy):</p> +<p class="original">You can convert a hash straight to an array with twice as many entries, alternating between key and value (and the reverse is equally easy):</p> <p>ã¨ã³ããªã2åã«ãã¦ããã·ã¥ãé åã«ç´æ¥å¤æãããã¨ãããã¼ã¨å¤ãå¤æ´ãããã¨ãã§ãã¾ã(ãã®éãã¾ãç°¡åã§ã):</p> <pre class="perl prettyprint"> my @scientists = %scientists; </pre> -<p class=original>However, unlike an array, the keys of a hash have <em>no underlying order</em>. They will be returned in whatever order is more efficient. So, notice the rearranged <em>order</em> but preserved <em>pairs</em> in the resulting array:</p> +<p class="original">However, unlike an array, the keys of a hash have <em>no underlying order</em>. They will be returned in whatever order is more efficient. So, notice the rearranged <em>order</em> but preserved <em>pairs</em> in the resulting array:</p> <p>ã§ãããé åã¨ã¯éããããã·ã¥ã®ãã¼ã¯<em>é çªãããã¾ãã</em>ãããå¹ççãªé çªã§è¿ã£ã¦ãã¾ãããã®ãããæ´åããç´ããã<em>é çª</em>ã«æ°ãã¤ãã¦ãã ãããããããçµæã®é åã®<em>ãã¢</em>ã¯ä¿æããã¾ã:</p> @@ -329,7 +329,7 @@ print "@scientists"; # something like "Einstein Albert Darwin Charles Newton Isaac" </pre> -<p class=original>To recap, you have to use <strong>square brackets</strong> to retrieve a value from an array, but you have to use <strong>braces</strong> to retrieve a value from a hash. The square brackets are effectively a numerical operator and the braces are effectively a string operator. The fact that the <em>index</em> supplied is a number or a string is of absolutely no significance:</p> +<p class="original">To recap, you have to use <strong>square brackets</strong> to retrieve a value from an array, but you have to use <strong>braces</strong> to retrieve a value from a hash. The square brackets are effectively a numerical operator and the braces are effectively a string operator. The fact that the <em>index</em> supplied is a number or a string is of absolutely no significance:</p> <p>è¦ç¹ãã¾ã¨ããã¨ãé åããå¤ãåãåºãã®ã«ã¯<strong>åè§ããã©ã±ãã</strong>ã使ããªããã°ããã¾ããããããã·ã¥ããå¤ãåãåºãã®ã¯<strong>ãã¬ã¼ã¹</strong>ã使ããªããã°ããã¾ãããæä¾ããã<em>ã¤ã³ããã¯ã¹</em>ãæ°åã§ãããæååã§ããã¨ãããã¨ã«ã¯ãéè¦æ§ã¯ããã¾ãã:</p> <pre class="perl prettyprint"> @@ -344,10 +344,10 @@ print $data{"0"}; # "blue" </pre> -<h3 class=original>Lists</h3> +<h3 class="original">Lists</h3> <h3>ãªã¹ã</h3> -<p class=original>A <i>list</i> in Perl is a different thing again from either an array or a hash. You've just seen several lists:</p> +<p class="original">A <i>list</i> in Perl is a different thing again from either an array or a hash. You've just seen several lists:</p> <p>Perlã«ããã<i>ãªã¹ã</i>ã¯é åãããã·ã¥ã¨ã¯éããã®ã§ããæ¢ã«ããã¤ãã®ãªã¹ããããã¾ãã:</p> <pre class="perl prettyprint"> @@ -367,9 +367,9 @@ ) </pre> -<p class=original><strong>A list is not a variable.</strong> A list is an ephemeral <em>value</em> which can be <em>assigned</em> to an array or a hash variable. This is why the syntax for declaring array and hash variables is identical. There are many situations where the terms "list" and "array" can be used interchangeably, but there are equally many where lists and arrays display subtly different and extremely confusing behaviour.</p> +<p class="original"><strong>A list is not a variable.</strong> A list is an ephemeral <em>value</em> which can be <em>assigned</em> to an array or a hash variable. This is why the syntax for declaring array and hash variables is identical. There are many situations where the terms "list" and "array" can be used interchangeably, but there are equally many where lists and arrays display subtly different and extremely confusing behaviour.</p> <p><strong>ãªã¹ãã¯å¤æ°ã§ã¯ããã¾ããã</strong>ãªã¹ãã¯ãã®å ´éãã®<em>å¤</em>ã§ãé åãããã·ã¥å¤æ°ã«<em>å²ãå½ã¦</em>ããã¾ãããã®ãã¨ã¯ãé åã¨ããã·ã¥ã®å¤æ°ã®å®£è¨ã®ã·ã³ã¿ãã¯ã¹ããä¸è´ãã¦ãããã¨ã®çç±ã§ãã"ãªã¹ã"ã¨"é å"ã®ç¨èªã交æå¯è½ãªç¶æ³ã¯å¤ãããã¾ãããåæ§ã«ããªã¹ãã¨é åãããã¶ãéã£ã¦è¦ããã¨ãããããããã®æ¯ãèãã«é常ã«æ··ä¹±ãã¾ãã</p> -<p class=original>Okay. Remember that <code>=></code> is just <code>,</code> in disguise and then look at this example:</p> +<p class="original">Okay. Remember that <code>=></code> is just <code>,</code> in disguise and then look at this example:</p> <p>ããã§ãããã <code>=></code>ã¯ããã ã®<code>,</code>ã§ãããã¨ãæãåºããè¿éããã¦ã次ã®ä¾ãè¦ã¦ãã ãã:</p> <pre class="perl prettyprint"> @@ -377,14 +377,14 @@ ("one" => 1, "three" => 3, "five" => 5) </pre> -<p class=original>The use of <code>=></code> hints that one of these lists is an array declaration and the other is a hash declaration. But on their own, neither of them are declarations of anything. They are just lists. <em>Identical</em> lists. Also:</p> +<p class="original">The use of <code>=></code> hints that one of these lists is an array declaration and the other is a hash declaration. But on their own, neither of them are declarations of anything. They are just lists. <em>Identical</em> lists. Also:</p> <p><code>=></code>ã®ä½¿ãæ¹ãä¸æ¹ã®ãªã¹ããé åã®å®£è¨ã§ãããã¨ã示ããä»æ¹ã¯ããã·ã¥ã®å®£è¨ã§ãããã¨ã示ãã¦ãã¾ããã§ããã2ã¤ã¨ããããèªèº«ãä½ã®å®£è¨ã§ãããã¾ããããã ã®ãªã¹ãã§ãã<em>åä¸ã®</em>ãªã¹ãã§ããã¾ã:</p> <pre class="perl prettyprint"> () </pre> -<p class=original>There aren't even hints here. This list could be used to declare an empty array or an empty hash and the <code>perl</code> interpreter clearly has no way of telling either way. Once you understand this odd aspect of Perl, you will also understand why the following fact must be true: <strong>List values cannot be nested.</strong> Try it:</p> +<p class="original">There aren't even hints here. This list could be used to declare an empty array or an empty hash and the <code>perl</code> interpreter clearly has no way of telling either way. Once you understand this odd aspect of Perl, you will also understand why the following fact must be true: <strong>List values cannot be nested.</strong> Try it:</p> <p>ãªãã®ãã³ããåå¨ãã¾ããããã®ãªã¹ãã¯ç©ºã®é åã¨ãã¦å®£è¨ããã¦ããã®ã§ãããããããã¨ããã«ã©ã®ããã·ã¥ã¨ãã¦ã§ããããã<code>perl</code>ã¤ã³ã¿ã¼ããªã¿ã«ã¯ãæããã«ã©ã¡ãã¨ãå¤æãããã¨ãã§ãã¾ãããPerlã®å¤ãã£ãä¸é¢ã§ããã¨ç解ãããªãã次ã®äºå®ãçã§ãããã¨ãã¾ãç解ããã§ããã: <strong>ãªã¹ãã®å¤ã¯ãã¹ãã§ãã¾ããã</strong> 試ãã¦ã¿ã¦ãã ãã:</p> @@ -402,7 +402,7 @@ ); </pre> -<p class=original>Perl has no way of knowing whether <code>("inner", "list", "several", "entries")</code> is supposed to be an inner array or an inner hash. Therefore, Perl assumes that it is neither and <strong>flattens the list out into a single long list</strong>:</p> +<p class="original">Perl has no way of knowing whether <code>("inner", "list", "several", "entries")</code> is supposed to be an inner array or an inner hash. Therefore, Perl assumes that it is neither and <strong>flattens the list out into a single long list</strong>:</p> <p>Perlã«ã¯ã<code>("inner"(訳註:å å´ã®), "list"(訳註:ãªã¹ãã), "several"(訳註:è¤æ°ã®), "entries"(訳註:å¤))</code>ãå å ãããé åãªã®ããããã·ã¥ãªã®ãã©ããããããã¾ããããã®ãããPerlã¯ãããã§ããªãã¨æ³å®ãã<strong>ã²ã¨ã¤ã®é·ããªã¹ãã«å¹³æ¿åãã¾ã</strong>:</p> @@ -416,7 +416,7 @@ print $array[6]; # "cherries" </pre> -<p class=original>The same is true whether the fat comma is used or not:</p> +<p class="original">The same is true whether the fat comma is used or not:</p> <p>ãã¡ããã«ã³ãã使ã£ã¦ãã¦ãããªãã¦ãåããçã§ã:</p> <pre class="perl original"> @@ -463,24 +463,24 @@ print @parts; </pre> -<p class=original>More on this shortly.</p> +<p class="original">More on this shortly.</p> <p>詳細ã¯å¾ã»ã©ã</p> <h2 class="original">Context</h2> <h2>ã³ã³ããã¹ã</h2> -<p class=original>Perl's most distinctive feature is that its code is <i>context-sensitive</i>. <strong>Every expression in Perl is evaluated either in scalar context or list context</strong>, depending on whether it is expected to produce a scalar or a list. Many Perl expressions and <a href="http://perldoc.perl.org/perlfunc.html">built-in functions</a> display radically different behaviour depending on the context in which they are evaluated.</p> +<p class="original">Perl's most distinctive feature is that its code is <i>context-sensitive</i>. <strong>Every expression in Perl is evaluated either in scalar context or list context</strong>, depending on whether it is expected to produce a scalar or a list. Many Perl expressions and <a href="http://perldoc.perl.org/perlfunc.html">built-in functions</a> display radically different behaviour depending on the context in which they are evaluated.</p> -<p>Perlã®æãç¹å¾´ã®ããã¨ããã¯ãã³ã¼ãã<i>ã³ã³ãã¯ã¹ãã»ã³ã·ãã£ã</i>ãªã¨ããã§ãã<strong>Perlã®å ¨ã¦ã®å¼ã¯ã¹ã«ã©ã³ã³ããã¹ãããªã¹ãã³ã³ããã¹ãã§è©ä¾¡ããã¾ã</strong>ãã¹ã«ã©ããªã¹ããã®ãããããä½ãããæå¾ ããã¦ãããã«ä¾åãã¾ããå¤ãã®Perlã®å¼ã¨<a href="http://perldoc.perl.org/perlfunc.html">çµè¾¼ã®é¢æ°</a>ã¯ããããè©ä¾¡ãããã³ã³ããã¹ãã«ãã£ã¦ãæ¯ãèãã«æ ¹æ¬çã«éããè¦ãã¾ãã</p> +<p>Perlã®æãç¹å¾´ã®ããã¨ããã¯ãã³ã¼ãã<i>ã³ã³ãã¯ã¹ãã»ã³ã·ãã£ã</i>ãªã¨ããã§ãã<strong>Perlã®å ¨ã¦ã®å¼ã¯ã¹ã«ã©ã³ã³ããã¹ãããªã¹ãã³ã³ããã¹ãã§è©ä¾¡ããã¾ã</strong>ãã¹ã«ã©ããªã¹ããã®ãããããä½ãããæå¾ ããã¦ãããã«ä¾åãã¾ããå¤ãã®Perlã®å¼ã¨<a href="http://perldoc.jp/docs/perl/perlfunc.pod">çµè¾¼ã®é¢æ°</a>ã¯ããããè©ä¾¡ãããã³ã³ããã¹ãã«ãã£ã¦ãæ¯ãèãã«æ ¹æ¬çã«éããè¦ãã¾ãã</p> -<p class=original>A scalar assignment such as <code>$scalar =</code> evaluates its expression in scalar context. In this case, the expression is <code>"Mendeleev"</code> and the returned value is the same scalar value <code>"Mendeleev"</code>:</p> +<p class="original">A scalar assignment such as <code>$scalar =</code> evaluates its expression in scalar context. In this case, the expression is <code>"Mendeleev"</code> and the returned value is the same scalar value <code>"Mendeleev"</code>:</p> <p><code>$scalar =</code>ã®ãããªã¹ã«ã©ã®å²ãå½ã¦ã¯ã¹ã«ã©ã³ã³ããã¹ãã¨ãã¦è©ä¾¡ããã¾ãããã®ã±ã¼ã¹ã§ã¯ããã®å¼ã¯<code>"Mendeleev"</code>ã¨ãè¿ãããå¤ã¯<code>"Mendeleev"</code>ã¨åãã¹ã«ã©ã«ãªãã¾ã:</p> <pre class="perl prettyprint"> my $scalar = "Mendeleev"; </pre> -<p class=original>An array or hash assignment such as <code>@array =</code> or <code>%hash =</code> evaluates its expression in list context. A list value evaluated in list context returns the list, which then gets fed in to populate the array or hash:</p> +<p class="original">An array or hash assignment such as <code>@array =</code> or <code>%hash =</code> evaluates its expression in list context. A list value evaluated in list context returns the list, which then gets fed in to populate the array or hash:</p> <p><code>@array =</code> ã <code>%hash =</code> ã®ãããªé åãããã·ã¥ã®å²ãå½ã¦ã¯ããªã¹ãã³ã³ããã¹ãã§è©ä¾¡ããã¾ãããªã¹ãã®å¤ã¯ãªã¹ãã³ã³ããã¹ãã§è©ä¾¡ããããªã¹ããè¿ãã¾ããé åãããã·ã¥ã«ä»£å ¥ãããããªã¨ãã§ã:</p> <pre class="perl prettyprint"> @@ -488,22 +488,22 @@ my %hash = ("Alpha" => "Beta", "Gamma" => "Pie"); </pre> -<p class=original>No surprises so far.</p> +<p class="original">No surprises so far.</p> <p>é©ããããªãã¨ã¯ããã¾ããã</p> -<p class=original>A scalar expression evaluated in list context turns into a single-element list:</p> +<p class="original">A scalar expression evaluated in list context turns into a single-element list:</p> <p>ã¹ã«ã©ã®å¼ã¯ãªã¹ãã³ã³ããã¹ãã§è©ä¾¡ãããã¨ãã²ã¨ã¤ã®å¤ã®ãªã¹ãã¨ãªãã¾ã:</p> <pre class="perl prettyprint"> my @array = "Mendeleev"; # same as 'my @array = ("Mendeleev");' </pre> -<p class=original>A list expression evaluated in scalar context returns <em>the final scalar in the list</em>:</p> +<p class="original">A list expression evaluated in scalar context returns <em>the final scalar in the list</em>:</p> <p>ãªã¹ãã®å¼ãã¹ã«ã©ã³ã³ããã¹ãã§è©ä¾¡ãããã¨ã<em>ãªã¹ãã®æå¾ã®ã¹ã«ã©</em>ãè¿ãã¾ã:</p> <pre class="perl prettyprint"> my $scalar = ("Alpha", "Beta", "Gamma", "Pie"); # Value of $scalar is now "Pie" </pre> -<p class=original>An array expression (an array is different from a list, remember?) evaluated in scalar context returns <em>the length of the array</em>:</p> +<p class="original">An array expression (an array is different from a list, remember?) evaluated in scalar context returns <em>the length of the array</em>:</p> <p>é åã®å¼(é åã¯ãªã¹ãã¨éãã¾ããè¦ãã¦ãï¼)ã¯ãã¹ã«ã©ã³ã³ããã¹ãã§ã¯<em>é åã®é·ã</em>ãè¿ãã¾ã:</p> <pre class="perl prettyprint"> @@ -511,7 +511,7 @@ my $scalar = @array; # Value of $scalar is now 4 </pre> <p class="original">The <code><a href="http://perldoc.perl.org/functions/print.html">print</a></code> built-in function evaluates all of its arguments in list context. In fact, <code>print</code> accepts an unlimited list of arguments and prints each one after the other, which means it can be used to print arrays directly:</p> -<p><code><a href="http://perldoc.perl.org/functions/print.html">print</a></code> çµè¾¼é¢æ°ã¯å ¨ã¦ã®å¼æ°ããªã¹ãã³ã³ããã¹ãã§è©ä¾¡ãã¾ãã<code>print</code>ã¯ç¡å¶éã®ãªã¹ãã®å¼æ°ãååããä¸ã¤ä¸ã¤åºåãã¾ããã¤ã¾ããé åãç´æ¥ä¸ãããã¨ãåºæ¥ã¾ãã</p> +<p><code><a href="http://perldoc.jp/func/print">print</a></code> çµè¾¼é¢æ°ã¯å ¨ã¦ã®å¼æ°ããªã¹ãã³ã³ããã¹ãã§è©ä¾¡ãã¾ãã<code>print</code>ã¯ç¡å¶éã®ãªã¹ãã®å¼æ°ãååããä¸ã¤ä¸ã¤åºåãã¾ããã¤ã¾ããé åãç´æ¥ä¸ãããã¨ãåºæ¥ã¾ãã</p> <pre class="perl prettyprint"> my @array = ("Alpha", "Beta", "Goo"); my $scalar = "-X-"; @@ -519,15 +519,15 @@ print $scalar, @array, 98; # "-X-AlphaBetaGoo98"; </pre> <p class="original">You can force any expression to be evaluated in scalar context using the <code><a href="http://perldoc.perl.org/functions/scalar.html">scalar</a></code> built-in function. In fact, this is why we use <code>scalar</code> to retrieve the length of an array.</p> -<p>ã©ã®ãããªå¼ã<code>scalar</code>çµè¾¼é¢æ°ã使ãã°ã¹ã«ã©ã³ã³ããã¹ãã§å¼·å¶çã«è©ä¾¡ãããã¨ãåºæ¥ã¾ãããã®ãã¨ãããªã<code><a href="http://perldoc.perl.org/functions/scalar.html">scalar</a></code>ãé åã®é·ããåãã®ã«ä½¿ãã®ãã®çç±ã§ãã</p> +<p>ã©ã®ãããªå¼ã<code>scalar</code>çµè¾¼é¢æ°ã使ãã°ã¹ã«ã©ã³ã³ããã¹ãã§å¼·å¶çã«è©ä¾¡ãããã¨ãåºæ¥ã¾ãããã®ãã¨ãããªã<code><a href="http://perldoc.jp/func/scalar">scalar</a></code>ãé åã®é·ããåãã®ã«ä½¿ãã®ãã®çç±ã§ãã</p> -<p class=original>You are not bound by law or syntax to return a scalar value when a subroutine is evaluated in scalar context, nor to return a list value in list context. As seen above, Perl is perfectly capable of fudging the result for you.</p> +<p class="original">You are not bound by law or syntax to return a scalar value when a subroutine is evaluated in scalar context, nor to return a list value in list context. As seen above, Perl is perfectly capable of fudging the result for you.</p> <p>ãµãã«ã¼ãã³ãã¹ã«ã©ã³ã³ããã¹ãã§è©ä¾¡ãããã¨ãã«ã¹ã«ã©ãè¿ããããªæ³å¾ãã·ã³ã¿ãã¯ã¹ã«ã¯ããªãã¯ç¸ããã¦ãã¾ããããã¾ãããªã¹ãã³ã³ããã¹ãã§ãªã¹ããè¿ããã¨ãã¾ãåãã§ããä¸ã§è¦ãããã«ãPerlã¯å®å ¨ã«ããªãã®ããã«çµæãä½ããã¨ãã§ãã¾ãã</p> -<h2 class=original>References and nested data structures</h2> +<h2 class="original">References and nested data structures</h2> <h2>ãªãã¡ã¬ã³ã¹ã¨ãã¹ãããããã¼ã¿æ§é </h2> -<p class=original>In the same way that lists cannot contain lists as elements, <strong>arrays and hashes cannot contain other arrays and hashes as elements.</strong> They can only contain scalars. Watch what happens when we try:</p> +<p class="original">In the same way that lists cannot contain lists as elements, <strong>arrays and hashes cannot contain other arrays and hashes as elements.</strong> They can only contain scalars. Watch what happens when we try:</p> <p>ãªã¹ããè¦ç´ ã¨ãã¦ãªã¹ããå«ããªãã®ã¨åæ§ã<strong>é åã¨ããã·ã¥ã¯ä»ã®é åãããã·ã¥ãè¦ç´ ã¨ãã¦æã¦ã¾ãã</strong>ã 両æ¹ã¨ãã¹ã«ã©ããæã¦ã¾ããã ä»ãã試ããã¨ãããè¦ã¦ãã ãã:</p> <pre class="perl prettyprint"> @@ -539,20 +539,20 @@ print $outer[3]; # "2" </pre> -<p class=original><code>$outer[3]</code> is a scalar, so it demands a scalar value. When you try to assign an array value like <code>@inner</code> to it, <code>@inner</code> is evaluated in scalar context. This is the same as assigning <code>scalar @inner</code>, which is the length of array <code>@inner</code>, which is 2.</p> +<p class="original"><code>$outer[3]</code> is a scalar, so it demands a scalar value. When you try to assign an array value like <code>@inner</code> to it, <code>@inner</code> is evaluated in scalar context. This is the same as assigning <code>scalar @inner</code>, which is the length of array <code>@inner</code>, which is 2.</p> <p><code>$outer[3]</code>ã¯ã¹ã«ã©ã§ãããã®ãããã¹ã«ã©ã®å¤ãè¦æ±ãã¾ãã<code>@inner</code>ã®ãããªé åãå²ãå½ã¦ããã¨ããã¨ã<code>@inner</code>ã¯ã¹ã«ã©ã³ã³ããã¹ãã§è©ä¾¡ããã¾ããã¤ã¾ãã<code>scalar @inner</code>ã¨åãã§ããé å<code>@inner</code>ã®é·ãã2ã«ãªãã¾ãã</p> -<p class=original>However, a scalar variable may contain a <i>reference</i> to any variable, including an array variable or a hash variable. This is how more complicated data structures are created in Perl.</p> +<p class="original">However, a scalar variable may contain a <i>reference</i> to any variable, including an array variable or a hash variable. This is how more complicated data structures are created in Perl.</p> <p>ã§ãã, ã¹ã«ã©å¤æ°ã¯ãé åå¤æ°ãããã·ã¥å¤æ°ãå«ããä»ã®å¤æ°ã¸ã®<i>ãªãã¡ã¬ã³ã¹</i>ãæã¦ã¾ããããããPerlã§ããè¤éãªãã¼ã¿æ§é ãä½ãæ¹æ³ã§ãã</p> -<p class=original>A reference is created using a backslash.</p> +<p class="original">A reference is created using a backslash.</p> <p>ãªãã¡ã¬ã³ã¹ã¯ããã¯ã¹ã©ãã·ã¥ã使ã£ã¦ä½ããã¾ãã</p> <pre class="perl prettyprint"> my $colour = "Indigo"; my $scalarRef = \$colour; </pre> -<p class=original>Any time you would use the name of a variable, you can instead just put some braces in, and, within the braces, put a <em>reference</em> to a variable instead.</p> +<p class="original">Any time you would use the name of a variable, you can instead just put some braces in, and, within the braces, put a <em>reference</em> to a variable instead.</p> <p>ãã¤ã§ããå¤æ°ã®ååã使ãã¾ãã代ããã«ãã¬ã¼ã¹ãç½®ãã¦ããã¬ã¼ã¹å ã«å¤æ°ã¸ã®<em>ãªãã¡ã¬ã³ã¹</em>ãç½®ãã¾ãã</p> <pre class="perl prettyprint"> print $colour; # "Indigo" @@ -560,14 +560,14 @@ print ${ $scalarRef }; # "Indigo" </pre> -<p class=original>As long as the result is not ambiguous, you can omit the braces too:</p> +<p class="original">As long as the result is not ambiguous, you can omit the braces too:</p> <p>çµæãææ§ã§ãªãéãããã¬ã¼ã¹ãçç¥ãããã¨ãã§ãã¾ã:</p> <pre class="perl prettyprint"> print $$scalarRef; # "Indigo" </pre> -<p class=original>If your reference is a reference to an array or hash variable, you can get data out of it using braces or using the more popular arrow operator, <code>-></code>:</p> +<p class="original">If your reference is a reference to an array or hash variable, you can get data out of it using braces or using the more popular arrow operator, <code>-></code>:</p> <p>ãªãã¡ã¬ã³ã¹ãé åãããã·ã¥å¤æ°ã®ãªãã¡ã¬ã³ã¹ã®å ´åããã¬ã¼ã¹ãããä¸è¬çãªã¢ãã¼æ¼ç®åã<code>-></code>ã使ã£ã¦ãã¼ã¿ãåãåºãã¾ã:</p> <pre class="perl prettyprint"> @@ -586,7 +586,7 @@ print $hashRef->{"Helium"}; # exactly the same thing - this is very common </pre> -<h3 class=original>Declaring a data structure</h3> +<h3 class="original">Declaring a data structure</h3> <h3>ãã¼ã¿æ§é ã宣è¨ãã</h3> <p class="original">Here are four examples, but in practice the last one is the most useful.</p> @@ -618,7 +618,7 @@ ); </pre> -<p class=original>That's obviously unnecessarily laborious, because you can shorten it to:</p> +<p class="original">That's obviously unnecessarily laborious, because you can shorten it to:</p> <p>ããã¯ãæããã«ä¸å¿ è¦ã§éª¨ã®æãã¾ãããªããªãã次ã®ããã«çç¥ã§ãã¾ã:</p> <pre class="perl prettyprint"> @@ -641,7 +641,7 @@ ); </pre> -<p class=original>It is also possible to declare <i>anonymous</i> arrays and hashes using different symbols. Use square brackets for an anonymous array and braces for an anonymous hash. The value returned in each case is a <em>reference</em> to the anonymous data structure in question. Watch carefully, this results in exactly the same <code>%account</code> as above:</p> +<p class="original">It is also possible to declare <i>anonymous</i> arrays and hashes using different symbols. Use square brackets for an anonymous array and braces for an anonymous hash. The value returned in each case is a <em>reference</em> to the anonymous data structure in question. Watch carefully, this results in exactly the same <code>%account</code> as above:</p> <p>å¥ã®è¨å·ã使ã£ã¦<i>ç¡å</i>é åãããã·ã¥ã宣è¨ãããã¨ãåºæ¥ã¾ããåè§ããã©ã±ãããç¡åé åã«ããã¬ã¼ã¹ãç¡åããã·ã¥ã«ä½¿ãã¾ãããããããè¿ãããå¤ã¯ãç¡åã®ãã¼ã¿æ§é ã®<em>ãªãã¡ã¬ã³ã¹</em>ã«ãªãã¾ãã注æãã¦è¦ã¦ãã ããã次ã®çµæã¯ãä¸ã®<code>%account</code>ã¨å ¨ãåãã§ã:</p> <pre class="perl prettyprint"> @@ -666,7 +666,7 @@ ); </pre> -<p class=original>Or, for short (and this is the form you should <em>actually</em> use when declaring complex data structures in-line):</p> +<p class="original">Or, for short (and this is the form you should <em>actually</em> use when declaring complex data structures in-line):</p> <p>ã¾ãã¯ãçç¥ããããã¨(ããã¦ãè¡ã§ãã¼ã¿è¤éãªæ§é ã宣è¨ããæã«ã<em>å®éã«</em>使ãã¹ãå½¢ã§ã):</p> <pre class="perl prettyprint"> @@ -707,7 +707,7 @@ print "\t", $owner2{"name"}, " (born ", $owner2{"DOB"}, ")\n"; </pre> -<p class=original>Or, for short:</p> +<p class="original">Or, for short:</p> <p>ã¾ãã¯, çç¥ãã¦:</p> <pre class="perl prettyprint"> @@ -721,7 +721,7 @@ print "\t", $owner2{"name"}, " (born ", $owner2{"DOB"}, ")\n"; </pre> -<p class=original>Or using references and the <code>-></code> operator:</p> +<p class="original">Or using references and the <code>-></code> operator:</p> <p>ã¾ãã¯ããªãã¡ã¬ã³ã¹ã¨<code>-></code> ã使ã£ã¦:</p> <pre class="perl prettyprint"> @@ -735,7 +735,7 @@ print "\t", $owner2Ref->{"name"}, " (born ", $owner2Ref->{"DOB"}, ")\n"; </pre> -<p class=original>And if we completely skip all the intermediate values:</p> +<p class="original">And if we completely skip all the intermediate values:</p> <p>ããã¦ãå ¨ã¦ã®ä¸éã®å¤ãã¹ããããããªã:</p> <pre class="perl prettyprint"> @@ -749,21 +749,21 @@ <h3 class="original">How to shoot yourself in the foot with array references</h3> <h3>é åã®ãªãã¡ã¬ã³ã¹ã§èªåã§èªåã®è¶³ãæã¤æ¹æ³</h3> -<p class=original>This array has five elements:</p> +<p class="original">This array has five elements:</p> <p>次ã®é åã«ã¯5ã¤ã®è¦ç´ ãããã¾ã:</p> <pre class="perl prettyprint"> my @array1 = (1, 2, 3, 4, 5); print @array1; # "12345" </pre> -<p class=original>This array, however, has ONE element (which happens to be a reference to an anonymous, five-element array):</p> +<p class="original">This array, however, has ONE element (which happens to be a reference to an anonymous, five-element array):</p> <p>ãããã次ã®é åã«ã¯*ã²ã¨ã¤*ã®è¦ç´ (ç¡åã®5ã¤ã®è¦ç´ ã®é åã®ãªãã¡ã¬ã³ã¹)ãããã¾ã:</p> <pre class="perl prettyprint"> my @array2 = [1, 2, 3, 4, 5]; print @array2; # e.g. "ARRAY(0x182c180)" </pre> -<p class=original>This <em>scalar</em> is a reference to an anonymous, five-element array:</p> +<p class="original">This <em>scalar</em> is a reference to an anonymous, five-element array:</p> <p>次㮠<em>ã¹ã«ã©</em> ã¯ãç¡åã®5ã¤ã®è¦ç´ ã®é åã®ãªãã¡ã¬ã³ã¹ã«ãªãã¾ã:</p> <pre class="perl prettyprint"> my $array3Ref = [1, 2, 3, 4, 5]; @@ -772,12 +772,12 @@ print @$array3Ref; # "12345" </pre> -<h2 class=original>Conditionals</h2> +<h2 class="original">Conditionals</h2> <h2>æ¡ä»¶</h2> <h3><code>if</code> ... <code>elsif</code> ... <code>else</code> ...</h3> -<p class=original>No surprises here, other than the spelling of <code>elsif</code>:</p> +<p class="original">No surprises here, other than the spelling of <code>elsif</code>:</p> <p><code>elsif</code>ã®ã¹ãã«ä»¥å¤ã«ã¯é©ããã®ã¯ããã¾ãã:</p> <pre class="perl prettyprint"> @@ -793,7 +793,7 @@ } </pre> -<p class=original>Perl provides a shorter "<i>statement</i> <code>if</code> <i>condition</i>" syntax which is highly recommended for short statements:</p> +<p class="original">Perl provides a shorter "<i>statement</i> <code>if</code> <i>condition</i>" syntax which is highly recommended for short statements:</p> <p>Perlã«ã¯ããçã "<i>ã¹ãã¼ãã¡ã³ã</i> <code>if</code> <i>æ¡ä»¶</i>"ã®ã·ã³ã¿ãã¯ã¹ãããã¾ããçãã¹ãã¼ãã¡ã³ãç¨ã«ãå¼·ãæ¨å¥¨ããã¾ã:</p> <pre class="perl prettyprint"> @@ -812,20 +812,20 @@ } </pre> -<p class=original><code>unless</code> blocks are generally best avoided like the plague because they are very confusing. An "<code>unless</code> [... <code>else</code>]" block can be trivially refactored into an "<code>if</code> [... <code>else</code>]" block by negating the condition [or by keeping the condition and swapping the blocks]. Mercifully, there is no <code>elsunless</code> keyword.</p> +<p class="original"><code>unless</code> blocks are generally best avoided like the plague because they are very confusing. An "<code>unless</code> [... <code>else</code>]" block can be trivially refactored into an "<code>if</code> [... <code>else</code>]" block by negating the condition [or by keeping the condition and swapping the blocks]. Mercifully, there is no <code>elsunless</code> keyword.</p> <p><code>unless</code>ãããã¯ã¯ç½ãã®ããã«é¿ããã®ãä¸çªã§ãããããã¯æ··ä¹±ã®ãã¨ã¨ãªãã¾ãã"<code>unless</code> [... <code>else</code>]"ãããã¯ã¯ç°¡åã«ã"<code>if</code> [... <code>else</code>]" ãããã¯ã«ãæ¡ä»¶ãå¦å®ãã[ã¾ãã¯ãæ¡ä»¶ããã®ã¾ã¾ã«ãããã¯ã交æãã]ãã¨ã§ãªãã¡ã¯ã¿ã§ãã¾ãã幸ãã <code>elsunless</code>ã®ãã¼ã¯ã¼ãã¯ããã¾ããã</p> -<p class=original>This, by comparison, is highly recommended because it is so easy to read:</p> +<p class="original">This, by comparison, is highly recommended because it is so easy to read:</p> <p>ä¸æ¹ã§ã以ä¸ã¯èªã¿ãããã®ããã«ãå¼·ãæ¨å¥¨ããã¾ã</p> <pre class="perl prettyprint"> print "Oh no it's too cold" unless $temperature > 15; </pre> -<h3 class=original>Ternary operator</h3> +<h3 class="original">Ternary operator</h3> <h3>ä¸é æ¼ç®å</h3> -<p class=original>The ternary operator <code>?:</code> allows simple <code>if</code> statements to be embedded in a statement. The canonical use for this is singular/plural forms:</p> +<p class="original">The ternary operator <code>?:</code> allows simple <code>if</code> statements to be embedded in a statement. The canonical use for this is singular/plural forms:</p> <p>ä¸é æ¼ç®å <code>?:</code> ã¯ãåç´ãª <code>if</code> ã¹ãã¼ãã¡ã³ããã²ã¨ã¤ã®ã¹ãã¼ãã¡ã³ãã«åãè¾¼ãã¾ããä¸é æ¼ç®åã®æ¨æºçãªä½¿ãæ¹ã¨ãã¦ãåæ°/è¤æ°ã®å½¢ãããã¾ã:</p> <pre class="perl prettyprint"> @@ -833,7 +833,7 @@ print "You gained ", $gain, " ", ($gain == 1 ? "experience point" : "experience points"), "!"; </pre> -<p class=original>Aside: singulars and plurals are best spelled out in full in both cases. Don't do something clever like the following, because anybody searching the codebase to replace the words "tooth" or "teeth" will never find this line:</p> +<p class="original">Aside: singulars and plurals are best spelled out in full in both cases. Don't do something clever like the following, because anybody searching the codebase to replace the words "tooth" or "teeth" will never find this line:</p> <p>ä½è«: 両æ¹ã®ã±ã¼ã¹ã®åæ°ã¨è¤æ°ãå®å ¨ã«æ¸ãåºããã¦ãã¾ãã決ãã¦ä»¥ä¸ã®ãããªå·§å¦ãªãã¨ãããªãã§ãã ãããã³ã¼ããæ¤ç´¢ãã¦ã"tooth"ã"teeth"ã®åèªãç½®ãæãããã¨ãã¦ãããã®è¡ããè¦ã¤ãããã¨ãã§ãã¾ããã</p> <pre class="perl prettyprint"> @@ -841,7 +841,7 @@ print "You lost ", $lost, " t", ($lost == 1 ? "oo" : "ee"), "th!"; </pre> -<p class=original>Ternary operators may be nested:</p> +<p class="original">Ternary operators may be nested:</p> <p>ä¸é æ¼ç®åã¯ãã¹ãã§ãã¾ã:</p> <pre class="perl prettyprint"> @@ -851,16 +851,16 @@ "some eggs"; </pre> -<p class=original><code>if</code> statements evaluate their conditions in scalar context. For example, <code>if(@array)</code> returns true if and only if <code>@array</code> has 1 or more elements. It doesn't matter what those elements are - they may contain <code>undef</code> or other false values for all we care.</p> +<p class="original"><code>if</code> statements evaluate their conditions in scalar context. For example, <code>if(@array)</code> returns true if and only if <code>@array</code> has 1 or more elements. It doesn't matter what those elements are - they may contain <code>undef</code> or other false values for all we care.</p> <p><code>if</code>æã§ã¯ããããã®æ¡ä»¶ãã¯ã¹ã«ã©ã³ã³ããã¹ãã§ä¾¡ããã¾ãã<code>if(@array)</code>ã¯ã<code>@array</code>ã«ã²ã¨ã¤ä»¥ä¸ã®ã¨ã¬ã¡ã³ããããå ´åã®ã¿ãçã¨ãªãã¾ããé åã®ä¸ã®å¤ãä½ãã¯åé¡ã«ãã¾ãã - å ¨ã¦ã<code>undef</code>ãä»ã®å½ã®å¤ã§ã</p> -<h2 class=original>Loops</h2> +<h2 class="original">Loops</h2> <h2>ã«ã¼ã</h2> -<p class=original>There's More Than One Way To Do It.</p> +<p class="original">There's More Than One Way To Do It.</p> <p>ããããã¯ã²ã¨ã¤ã§ã¯ããã¾ããã</p> -<p class=original>Perl has a conventional <code>while</code> loop:</p> +<p class="original">Perl has a conventional <code>while</code> loop:</p> <p>Perlã®æ £ä¾çãª<code>while</code> ã«ã¼ã:</p> <pre class="perl prettyprint"> @@ -903,7 +903,7 @@ } until ($i >= scalar @array); </pre> -<p class=original>Basic C-style <code>for</code> loops are available too. Notice how we put a <code>my</code> inside the <code>for</code> statement, declaring <code>$i</code> only for the scope of the loop:</p> +<p class="original">Basic C-style <code>for</code> loops are available too. Notice how we put a <code>my</code> inside the <code>for</code> statement, declaring <code>$i</code> only for the scope of the loop:</p> <p>åºæ¬çãªC-styleã®<code>for</code>ã«ã¼ããå©ç¨ã§ãã¾ãã<code>my</code>ã<code>for</code>æã®å å´ã«ç½®ãæ¹æ³ã«æ³¨æãã¦ãã ããã宣è¨ããã<code>$i</code>ã¯ã«ã¼ãã®ã¹ã³ã¼ãã§ã®ã¿æå¹ã§ã:</p> <pre class="perl prettyprint"> @@ -920,8 +920,8 @@ } </pre> -<p class=original>If you do need the indices, the <a href="http://perldoc.perl.org/perlop.html#Range-Operators">range operator</a> <code>..</code> creates an anonymous list of integers:</p> -<p>è¤æ°ã®ã¤ã³ããã¯ã¹ãå¿ è¦ãªãã<a href="http://perldoc.perl.org/perlop.html#Range-Operators">ç¯å²æ¼ç®å</a><code>..</code>ã§æ´æ°ã®ç¡åãªã¹ããä½ãã¾ã:</p> +<p class="original">If you do need the indices, the <a href="http://perldoc.perl.org/perlop.html#Range-Operators">range operator</a> <code>..</code> creates an anonymous list of integers:</p> +<p>è¤æ°ã®ã¤ã³ããã¯ã¹ãå¿ è¦ãªãã<a href="http://perldoc.jp/docs/perl/perlop.pod#Range32Operators">ç¯å²æ¼ç®å</a><code>..</code>ã§æ´æ°ã®ç¡åãªã¹ããä½ãã¾ã:</p> <pre class="perl prettyprint"> foreach my $i ( 0 .. $#array ) { @@ -929,7 +929,7 @@ } </pre> -<p class=original>You can't iterate over a hash. However, you can iterate over its keys. Use the <code>keys</code> built-in function to retrieve an array containing all the keys of a hash. Then use the <code>foreach</code> approach that we used for arrays:</p> +<p class="original">You can't iterate over a hash. However, you can iterate over its keys. Use the <code>keys</code> built-in function to retrieve an array containing all the keys of a hash. Then use the <code>foreach</code> approach that we used for arrays:</p> <p>ããã·ã¥ã¯ã¤ãã¬ã¼ãã§ãã¾ããããã®ãã¼ãã¤ãã¬ã¼ãã§ãã¾ããçµè¾¼é¢æ°ã®<code>keys</code>ã使ã£ã¦ãããã·ã¥ã®å ¨ã¦ã®ãã¼ãå«ãé åãåãåºãã¦ãã ããããããããé åã§ä½¿ã£ã<code>foreach</code>ã®ã¢ããã¼ãã使ãã¾ã:</p> <pre class="perl prettyprint"> @@ -938,7 +938,7 @@ } </pre> -<p class=original>Since a hash has no underlying order, the keys may be returned in any order. Use the <code>sort</code> built-in function to sort the array of keys alphabetically beforehand:</p> +<p class="original">Since a hash has no underlying order, the keys may be returned in any order. Use the <code>sort</code> built-in function to sort the array of keys alphabetically beforehand:</p> <p>ããã·ã¥ã«ã¯é çªãããã¾ããã®ã§ãkeysã¯ã©ã®ãããªé çªã§ãæ»ãã¾ããçµè¾¼ã®<code>sort</code>é¢æ°ã使ã£ã¦ãã¢ã«ãã¡ãããé ã§ãã¼ã®é åãã½ã¼ãã§ãã¾ã:</p> <pre class="perl prettyprint"> foreach my $key (sort keys %scientists) { @@ -947,7 +947,7 @@ </pre> <p class="original">If you don't provide an explicit iterator, Perl uses a default iterator, <code>$_</code>. <code>$_</code> is the first and friendliest of <a href="http://perldoc.perl.org/perlvar.html">built-in variables</a>:</p> -<p>æ示çãªã¤ãã¬ã¼ã¿ã使ããªããã°ãPerlã¯ããã©ã«ãã®ã¤ãã¬ã¼ã¿ã¨ãã¦<code>$_</code>ã使ãã¾ãã<code>$_</code>ã¯æåã®æããã¬ã³ããªã¼ãª<a href="http://perldoc.perl.org/perlvar.html">çµè¾¼ã®å¤æ°</a>ã§ã:</p> +<p>æ示çãªã¤ãã¬ã¼ã¿ã使ããªããã°ãPerlã¯ããã©ã«ãã®ã¤ãã¬ã¼ã¿ã¨ãã¦<code>$_</code>ã使ãã¾ãã<code>$_</code>ã¯æåã®æããã¬ã³ããªã¼ãª<a href="http://perldoc.jp/docs/perl/perlvar.pod">çµè¾¼ã®å¤æ°</a>ã§ã:</p> <pre class="perl prettyprint"> foreach ( @array ) { @@ -961,26 +961,26 @@ print $_ foreach @array; </pre> -<h3 class=original>Loop control</h3> +<h3 class="original">Loop control</h3> <h3>ã«ã¼ãå¶å¾¡</h3> -<p class=original><code>next</code> and <code>last</code> can be used to control the progress of a loop. In most programming languages these are known as <code>continue</code> and <code>break</code> respectively. We can also optionally provide a label for any loop. By convention, labels are written in <code>ALLCAPITALS</code>. Having labelled the loop, <code>next</code> and <code>last</code> may target that label. This example finds primes below 100:</p> +<p class="original"><code>next</code> and <code>last</code> can be used to control the progress of a loop. In most programming languages these are known as <code>continue</code> and <code>break</code> respectively. We can also optionally provide a label for any loop. By convention, labels are written in <code>ALLCAPITALS</code>. Having labelled the loop, <code>next</code> and <code>last</code> may target that label. This example finds primes below 100:</p> <p><code>next</code> 㨠<code>last</code>ã¯ã«ã¼ãé²ã¿ãå¶å¾¡ããã®ã«ä½¿ããã¾ããå¤ãã®ããã°ã©ãã³ã°è¨èªã§ã¯ãããããã<code>continue</code> 㨠<code>break</code>ã¨ãªã£ã¦ãã¾ãããªãã·ã§ã³ã§ãã©ã®ã«ã¼ãã«ãã©ãã«ãã¤ãããã¨ãã§ãã¾ããæ £ä¾ã«ãããã©ãã«ã¯<code>å ¨ã¦å¤§æåã§</code>æ¸ããã¨ã«ãªã£ã¦ãã¾ããã«ã¼ãã«ã©ãã«ãã¤ãããã¨ã§ã<code>next</code> 㨠<code>last</code> ã«ã©ãã«ã対象ã«ã§ãã¾ãã100以ä¸ã®ç´ æ°ãè¦ã¤ããä¾ã§ã:</p> <pre class="perl prettyprint"> CANDIDATE: for my $candidate ( 3 .. 100 ) { - for my $divisor ( 2 .. <a href="http://perldoc.perl.org/functions/sqrt.html">sqrt</a> $candidate ) { + for my $divisor ( 2 .. <a href="http://perldoc.jp/func/sqrt">sqrt</a> $candidate ) { next CANDIDATE if $candidate % $divisor == 0; } print $candidate." is prime\n"; } </pre> -<h2 class=original>Array functions</h2> +<h2 class="original">Array functions</h2> <h2>é åé¢æ°</h2> -<h3 class=original>In-place array modification</h3> +<h3 class="original">In-place array modification</h3> <h3>ãã®å ´ã§é åãå¤æ´ãã</h3> <p class="original">We'll use <code>@stack</code> to demonstrate these:</p> @@ -992,49 +992,49 @@ print @stack; # "FredEileenDeniseCharlie" </pre> -<p class=original><code><a href="http://perldoc.perl.org/functions/pop.html">pop</a></code> extracts and returns the final element of the array. This can be thought of as the top of the stack:</p> -<p><code><a href="http://perldoc.perl.org/functions/pop.html">pop</a></code> ã¯é åã®æå¾ã®è¦ç´ ãå¼ãåºãã¦è¿ãã¾ããã¹ã¿ãã¯ã®ä¸ã¨ãã¦èãããã¾ã:</p> +<p class="original"><code><a href="http://perldoc.perl.org/functions/pop.html">pop</a></code> extracts and returns the final element of the array. This can be thought of as the top of the stack:</p> +<p><code><a href="http://perldoc.jp/func/pop">pop</a></code> ã¯é åã®æå¾ã®è¦ç´ ãå¼ãåºãã¦è¿ãã¾ããã¹ã¿ãã¯ã®ä¸ã¨ãã¦èãããã¾ã:</p> <pre class="perl prettyprint"> print pop @stack; # "Charlie" print @stack; # "FredEileenDenise" </pre> -<p class=original><code><a href="http://perldoc.perl.org/functions/push.html">push</a></code> appends extra elements to the end of the array:</p> -<p><code><a href="http://perldoc.perl.org/functions/push.html">push</a></code> ã¯è¿½å ã®è¦ç´ ãé åã®æå¾ã«ä»å ãã¾ã:</p> +<p class="original"><code><a href="http://perldoc.perl.org/functions/push.html">push</a></code> appends extra elements to the end of the array:</p> +<p><code><a href="http://perldocjp/func/push">push</a></code> ã¯è¿½å ã®è¦ç´ ãé åã®æå¾ã«ä»å ãã¾ã:</p> <pre class="perl prettyprint"> push @stack, "Bob", "Alice"; print @stack; # "FredEileenDeniseBobAlice" </pre> -<p class=original><code><a href="http://perldoc.perl.org/functions/shift.html">shift</a></code> extracts and returns the first element of the array:</p> -<p><code><a href="http://perldoc.perl.org/functions/shift.html">shift</a></code> ã¯é åã®æåã®è¦ç´ ãå¼ãåºãã¦è¿ãã¾ã:</p> +<p class="original"><code><a href="http://perldoc.perl.org/functions/shift.html">shift</a></code> extracts and returns the first element of the array:</p> +<p><code><a href="http://perldoc.perl.org/func/shift">shift</a></code> ã¯é åã®æåã®è¦ç´ ãå¼ãåºãã¦è¿ãã¾ã:</p> <pre class="perl prettyprint"> print shift @stack; # "Fred" print @stack; # "EileenDeniseBobAlice" </pre> -<p class=original><code><a href="http://perldoc.perl.org/functions/unshift.html">unshift</a></code> inserts new elements at the beginning of the array:</p> -<p><code><a href="http://perldoc.perl.org/functions/unshift.html">unshift</a></code> é åã®æåã«æ°ããè¦ç´ ãæ¿å ¥ãã¾ã:</p> +<p class="original"><code><a href="http://perldoc.perl.org/functions/unshift.html">unshift</a></code> inserts new elements at the beginning of the array:</p> +<p><code><a href="http://perldoc.jp/func/unshift">unshift</a></code> é åã®æåã«æ°ããè¦ç´ ãæ¿å ¥ãã¾ã:</p> <pre class="perl prettyprint"> unshift @stack, "Hank", "Grace"; print @stack; # "HankGraceEileenDeniseBobAlice" </pre> -<p class=original><code>pop</code>, <code>push</code>, <code>shift</code> and <code>unshift</code> are all special cases of <code><a href="http://perldoc.perl.org/functions/splice.html">splice</a></code>. <code>splice</code> removes and returns an array slice, replacing it with a different array slice:</p> -<p><code>pop</code>ã<code>push</code>ã <code>shift</code>ã<code>unshift</code> ã¯ãå ¨ã¦ã<code><a href="http://perldoc.perl.org/functions/splice.html">splice</a></code>ã®ç¹å¥ãªã±ã¼ã¹ã§ãã<code>splice</code> ã¯ãé åã®ã¹ã©ã¤ã¹ãåé¤ãã¦ãè¿ãã¾ããå¥ã®é åã¹ã©ã¤ã¹ã§ãããç½®ãæãã¾ã:</p> +<p class="original"><code>pop</code>, <code>push</code>, <code>shift</code> and <code>unshift</code> are all special cases of <code><a href="http://perldoc.perl.org/functions/splice.html">splice</a></code>. <code>splice</code> removes and returns an array slice, replacing it with a different array slice:</p> +<p><code>pop</code>ã<code>push</code>ã <code>shift</code>ã<code>unshift</code> ã¯ãå ¨ã¦ã<code><a href="http://perldoc.jp/func/splice">splice</a></code>ã®ç¹å¥ãªã±ã¼ã¹ã§ãã<code>splice</code> ã¯ãé åã®ã¹ã©ã¤ã¹ãåé¤ãã¦ãè¿ãã¾ããå¥ã®é åã¹ã©ã¤ã¹ã§ãããç½®ãæãã¾ã:</p> <pre class="perl prettyprint"> print splice(@stack, 1, 4, "<<<", ">>>"); # "GraceEileenDeniseBob" print @stack; # "Hank<<<>>>Alice" </pre> -<h3 class=original>Creating new arrays from old</h3> +<h3 class="original">Creating new arrays from old</h3> <h3>å¤ãé åããæ°ããé åãä½ã</h3> -<p class=original>Perl provides the following functions which act on arrays to create other arrays.</p> +<p class="original">Perl provides the following functions which act on arrays to create other arrays.</p> <p>Perlã«ã¯ä»¥ä¸ã®é¢æ°ããããé åã«å¯¾ãã¦ãæ°ããé åãä½ãã¾ã</p> <p class="original">The <code><a href="http://perldoc.perl.org/functions/join.html">join</a></code> function concatenates many strings into one:</p> -<p><code><a href="http://perldoc.perl.org/functions/join.html">join</a></code> é¢æ°ã¯å¤ãã®æååãä¸ã¤ã«çµåãã¾ã:</p> +<p><code><a href="http://perldoc.jp/func/join">join</a></code> é¢æ°ã¯å¤ãã®æååãä¸ã¤ã«çµåãã¾ã:</p> <pre class="perl prettyprint"> my @elements = ("Antimony", "Arsenic", "Aluminum", "Selenium"); @@ -1043,8 +1043,8 @@ print join(", ", @elements); # "Antimony, Arsenic, Aluminum, Selenium" </pre> -<p class=original>In list context, the <code><a href="http://perldoc.perl.org/functions/reverse.html">reverse</a></code> function returns a list in reverse order. In scalar context, <code>reverse</code> concatenates the whole list together and then reverses it as a single word.</p> -<p>ãªã¹ãã³ã³ããã¹ãã§ã¯ã<code><a href="http://perldoc.perl.org/functions/reverse.html">reverse</a></code>é¢æ°ã¯éé ã®ãªã¹ããè¿ãã¾ããã¹ã«ã©ã¼ã³ã³ããã¹ãã§ã¯<code>reverse</code>ãªã¹ãã®å ¨ã¦ãã¤ãªãã¦ä¸ã¤ã®æååã¨ãã¦ããããéé ã«ãã¾ãã</p> +<p class="original">In list context, the <code><a href="http://perldoc.perl.org/functions/reverse.html">reverse</a></code> function returns a list in reverse order. In scalar context, <code>reverse</code> concatenates the whole list together and then reverses it as a single word.</p> +<p>ãªã¹ãã³ã³ããã¹ãã§ã¯ã<code><a href="http://perldoc.jp/func/reverse">reverse</a></code>é¢æ°ã¯éé ã®ãªã¹ããè¿ãã¾ããã¹ã«ã©ã¼ã³ã³ããã¹ãã§ã¯<code>reverse</code>ãªã¹ãã®å ¨ã¦ãã¤ãªãã¦ä¸ã¤ã®æååã¨ãã¦ããããéé ã«ãã¾ãã</p> <pre class="perl prettyprint"> print reverse("Hello", "World"); # "WorldHello" print reverse("HelloWorld"); # "HelloWorld" @@ -1052,8 +1052,8 @@ print scalar reverse("Hello", "World"); # "dlroWolleH" </pre> -<p class=original>The <code><a href="http://perldoc.perl.org/functions/map.html">map</a></code> function takes an array as input and applies an operation to every scalar <code>$_</code> in this array. It then constructs a new array out of the results. The operation to perform is provided in the form of a single expression inside braces:</p> -<p><code>map</code>é¢æ°ã¯å ¥åã¨ãã¦é åãã¨ããé åå ã®å ¨ã¦ã®ã¹ã«ã© <code>$_</code>ãæä½ãã¾ããçµæã¨ãã¦æ°ããé åãä½ãã¾ããæä½ã¯ã²ã¨ã¤ã®ãã¬ã¼ã¹ã§æ¸¡ãã¾ã:</p> +<p class="original">The <code><a href="http://perldoc.perl.org/functions/map.html">map</a></code> function takes an array as input and applies an operation to every scalar <code>$_</code> in this array. It then constructs a new array out of the results. The operation to perform is provided in the form of a single expression inside braces:</p> +<p><code><a href="http://perldoc.jp/func/map">map</a></code>é¢æ°ã¯å ¥åã¨ãã¦é åãã¨ããé åå ã®å ¨ã¦ã®ã¹ã«ã© <code>$_</code>ãæä½ãã¾ããçµæã¨ãã¦æ°ããé åãä½ãã¾ããæä½ã¯ã²ã¨ã¤ã®ãã¬ã¼ã¹ã§æ¸¡ãã¾ã:</p> <pre class="perl prettyprint"> my @capitals = ("Baton Rouge", "Indianapolis", "Columbus", "Montgomery", "Helena", "Denver", "Boise"); @@ -1062,26 +1062,26 @@ # "BATON ROUGE, INDIANAPOLIS, COLUMBUS, MONTGOMERY, HELENA, DENVER, BOISE" </pre> -<p class=original>The <code><a href="http://perldoc.perl.org/functions/grep.html">grep</a></code> function takes an array as input and returns a filtered array as output. The syntax is similar to <code>map</code>. This time, the second argument is evaluated for each scalar <code>$_</code> in the input array. If a boolean true value is returned, the scalar is put into the output array, otherwise not.</p> -<p><code>grep</code>é¢æ°ã¯å ¥åã¨ãã¦é åãã¨ãããã£ã«ã¿ã¼ãããé åãåºåãã¾ããã·ã³ã¿ãã¯ã¹ã¯<code>map</code>ã¨ä¼¼ã¦ãã¾ããä»åº¦ã¯ã第äºå¼æ°ã¯å ¥åãããé åã®åã¹ã«ã©<code>$_</code>ãè©ä¾¡ããã¾ãããã¼ãªã¢ã³ã§çã®å¤ãæ»ãã°ãã¹ã«ã©ã¯é åã¨ãã¦åºåããã¾ãããããã§ãªããã°ãåºåããã¾ããã</p> +<p class="original">The <code><a href="http://perldoc.perl.org/functions/grep.html">grep</a></code> function takes an array as input and returns a filtered array as output. The syntax is similar to <code>map</code>. This time, the second argument is evaluated for each scalar <code>$_</code> in the input array. If a boolean true value is returned, the scalar is put into the output array, otherwise not.</p> +<p><code><a href="http://perldoc.jp/func/grep">grep</a></code>é¢æ°ã¯å ¥åã¨ãã¦é åãã¨ãããã£ã«ã¿ã¼ãããé åãåºåãã¾ããã·ã³ã¿ãã¯ã¹ã¯<code>map</code>ã¨ä¼¼ã¦ãã¾ããä»åº¦ã¯ã第äºå¼æ°ã¯å ¥åãããé åã®åã¹ã«ã©<code>$_</code>ãè©ä¾¡ããã¾ãããã¼ãªã¢ã³ã§çã®å¤ãæ»ãã°ãã¹ã«ã©ã¯é åã¨ãã¦åºåããã¾ãããããã§ãªããã°ãåºåããã¾ããã</p> <pre class="perl prettyprint"> print join ", ", grep { length $_ == 6 } @capitals; # "Helena, Denver" </pre> -<p class=original>Obviously, the length of the resulting array is the <em>number of successful matches</em>, which means you can use <code>grep</code> to quickly check whether an array contains an element:</p> +<p class="original">Obviously, the length of the resulting array is the <em>number of successful matches</em>, which means you can use <code>grep</code> to quickly check whether an array contains an element:</p> <p>å½ç¶ãçµæã®é åã®é·ãã¯ã<em>ãããã«æåããæ°</em>ã«ãªãã¾ãããã®ã¨ãã¨ã¯ã<code>grep</code>ãé åã«è¦ç´ ããããã©ãããç´ æ©ããã§ãã¯ããã®ã«ä½¿ãããã¨ãæå³ãã¾ãã:</p> <pre class="perl prettyprint"> print scalar grep { $_ eq "Columbus" } @capitals; # "1" </pre> -<p class=original><code>grep</code> and <code>map</code> may be combined to form <i><a href="https://en.wikipedia.org/wiki/List_comprehension">list comprehensions</a></i>, an exceptionally powerful feature conspicuously absent from many other programming languages.</p> +<p class="original"><code>grep</code> and <code>map</code> may be combined to form <i><a href="https://en.wikipedia.org/wiki/List_comprehension">list comprehensions</a></i>, an exceptionally powerful feature conspicuously absent from many other programming languages.</p> <p><code>grep</code> 㨠<code>map</code> ã¯ã<i><a href="https://en.wikipedia.org/wiki/List_comprehension">ãªã¹ãå å«</a></i>ã®å½¢ã«å«ã¾ãã¾ããä»ã®å¤ãã®ããã°ã©ãã³ã°è¨èªã«ç®ç«ã£ã¦æ¬ ãã¦ãããä¾å¤çã«å¼·åãªæ©è½ã§ãã</p> -<p class=original>By default, the <code><a href="http://perldoc.perl.org/functions/sort.html">sort</a></code> function returns the input array, sorted into lexical (alphabetical) order:</p> -<p>ããã©ã«ãã§ã¯ã<code>sort</code>é¢æ°ã¯å ¥åãããé åãæåé (ã¢ã«ãã¡ãããé )ã«ä¸¦ã³ããã¾ã:</p> +<p class="original">By default, the <code><a href="http://perldoc.perl.org/functions/sort.html">sort</a></code> function returns the input array, sorted into lexical (alphabetical) order:</p> +<p>ããã©ã«ãã§ã¯ã<code><a href="http://perldoc.jp/func/sort">sort</a></code>é¢æ°ã¯å ¥åãããé åãæåé (ã¢ã«ãã¡ãããé )ã«ä¸¦ã³ããã¾ã:</p> <pre class="perl prettyprint"> my @elevations = (19, 1, 2, 100, 3, 98, 100, 1056); @@ -1093,7 +1093,7 @@ <p class="original">However, similar to <code>grep</code> and <code>map</code>, you may supply some code of your own. Sorting is always performed using a series of comparisons between two elements. Your block receives <code>$a</code> and <code>$b</code> as inputs and should return -1 if <code>$a</code> is "less than" <code>$b</code>, 0 if they are "equal" or 1 if <code>$a</code> is "greater than" <code>$b</code>.</p> <p>ãããã<code>grep</code> 㨠<code>map</code>ã¨ä¼¼ã¦ãèªåã®ã³ã¼ãã渡ããã¨ãåºæ¥ã¾ããã½ã¼ãã¯å¸¸ã«2è¦ç´ éã®ä¸é£ã®æ¯è¼ã使ã£ã¦ããã¾ããã³ã¼ããããã¯ã¯ã<code>$a</code>ã¨<code>$b</code>ãåãã<code>$a</code>ã<code>$b</code>"ããå°ã"ããã° -1ã"åã"ã§ããã° 0ã<code>$a</code>ã<code>$b</code>"ãã大ã"ããã° 1 ãè¿ãã¾ãã</p> -<p class=original>The <code>cmp</code> operator does exactly this for strings:</p> +<p class="original">The <code>cmp</code> operator does exactly this for strings:</p> <p><code>cmp</code> æ¼ç®åã¯æååã«å¯¾ãã¦ãã¾ãã«ããããã¾ã:</p> <pre class="perl prettyprint"> @@ -1101,7 +1101,7 @@ # "1, 100, 100, 1056, 19, 2, 3, 98" </pre> -<p class=original>The "spaceship operator", <code><=></code>, does the same for numbers:</p> +<p class="original">The "spaceship operator", <code><=></code>, does the same for numbers:</p> <p>"ã¹ãã¼ã¹ã·ããæ¼ç®å", <code><=></code>ã¯ãæ°åã«å¯¾ãã¦åããã¨ããã¾ã:</p> <pre class="perl prettyprint"> @@ -1109,7 +1109,7 @@ # "1, 2, 3, 19, 98, 100, 100, 1056" </pre> -<p class=original><code>$a</code> and <code>$b</code> are always scalars, but they can be references to quite complex objects which are difficult to compare. If you need more space for the comparison, you can create a separate subroutine and provide its name instead:</p> +<p class="original"><code>$a</code> and <code>$b</code> are always scalars, but they can be references to quite complex objects which are difficult to compare. If you need more space for the comparison, you can create a separate subroutine and provide its name instead:</p> <p><code>$a</code> 㨠<code>$b</code> ã¯å¸¸ã«ã¹ã«ã©ã¼ã§ãããæ¯è¼ãé£ããé常ã«è¤éãªãªãã¸ã§ã¯ãã®ãªãã¡ã¬ã³ã¹ããããã¾ããæ¯è¼ã«ããã¹ãã¼ã¹ãå¿ è¦ãªããå¥ã®ãµãã«ã¼ãã³ãä½ãã代ããã«ãã®ååã渡ãã¾ã:</p> <pre class="perl prettyprint"> @@ -1121,13 +1121,13 @@ print join ", ", sort comparator @elevations; </pre> -<p class=original>You can't do this for <code>grep</code> or <code>map</code> operations.</p> +<p class="original">You can't do this for <code>grep</code> or <code>map</code> operations.</p> <p>åããã¨ã¯ã<code>grep</code> ã <code>map</code> ã§ã¯ã§ãã¾ããã</p> -<p class=original>Notice how the subroutine and block are never explicitly provided with <code>$a</code> and <code>$b</code>. Like <code>$_</code>, <code>$a</code> and <code>$b</code> are, in fact, global variables which are <em>populated</em> with a pair of values to be compared each time.</p> +<p class="original">Notice how the subroutine and block are never explicitly provided with <code>$a</code> and <code>$b</code>. Like <code>$_</code>, <code>$a</code> and <code>$b</code> are, in fact, global variables which are <em>populated</em> with a pair of values to be compared each time.</p> <p>ãµãã«ã¼ãã³ã¨ãããã¯ã¯ <code>$a</code> 㨠<code>$b</code>ã¨ä¸ç·ã«ã¯æ¸¡ããã¾ããã<code>$_</code>ã®ããã«ã <code>$a</code>ã¨<code>$b</code>ã¯ãå®éãã°ãã¼ãã«å¤æ°ã§ããã®æã ã«ãæ¯è¼ãããå¤ã®ãã¢ã§<em>åããã</em>ã¾ã</p> -<h2 class=original>Built-in functions</h2> +<h2 class="original">Built-in functions</h2> <h2>çµè¾¼é¢æ°</h2> <p class="original">By now you have seen at least a dozen built-in functions: <code>print</code>, <code>sort</code>, <code>map</code>, <code>grep</code>, <code>keys</code>, <code>scalar</code> and so on. Built-in functions are one of Perl's greatest strengths. They</p> <p>ä»ã¾ã§ã§ãå°ãªãã¨ãããããçµè¾¼é¢æ°ãåºã¦ãã¾ãã: <code>print</code>, <code>sort</code>, <code>map</code>, <code>grep</code>, <code>keys</code>, <code>scalar</code> ãªã©ã çµè¾¼é¢æ°ã¯Perlã®æãå大ãªå¼·ã¿ã®ã²ã¨ã¤ã§ãããããã¯ã</p> @@ -1147,7 +1147,7 @@ <ul> <li>ãããããã</li> <li>ã¨ã¦ã便å©</li> - <li><a href="http://perldoc.perl.org/perlfunc.html">åºãããã¥ã³ãå</a>ããã¦ãã</li> + <li><a href="http://perldoc.jp/docs/perl/perlfunc.pod">åºãããã¥ã³ãå</a>ããã¦ãã</li> <li>ã·ã³ã¿ãã¯ã¹ã§å¤§ããç°ãªãã®ã§ãããã¥ã¡ã³ããè¦ããã¨</li> <li>å¼æ°ã¨ãã¦æ£è¦è¡¨ç¾ãåãä»ãããã®ããã</li> <li>å¼æ°ã¨ãã¦å®å ¨ãªã³ã¼ããããã¯ãåãä»ãããã®ããã</li> @@ -1156,21 +1156,21 @@ <li>å¼æ°ãå°ãªãããå ´åã«ãèªåèªèº«ã§å¼æ°ãåãããã®ããã</li> <li>ææ§ãªç¶æ³ã§ãªããã°ãä¸è¬çã«å¼æ°ã®ã¾ããã«æ¬å¼§ã¯ä¸è¦</li> </ul> -<p class=original>The best advice regarding built-in functions is to know that they exist, so that you can <strong>use them</strong>. If you are carrying out a task which feels like it's low-level and common enough that it's been done many times before, the chances are that it has.</p> +<p class="original">The best advice regarding built-in functions is to know that they exist, so that you can <strong>use them</strong>. If you are carrying out a task which feels like it's low-level and common enough that it's been done many times before, the chances are that it has.</p> <p>çµè¾¼é¢æ°ãåå¨ãã¦ãããã¨ãç¥ããã¨ã«é¤¨ããæãè¯ãã¢ããã¤ã¹ã¯ã<strong>使ã£ã¦ã¿ã</strong>ãã¨ã§ããä½ã¬ãã«ã§ä»¥åã«ä½åº¦ãè¡ã£ã¦ããååã«å ±éã ã¨æããã¿ã¹ã¯ãå®è¡ãã¦ãããªãããã®ãã£ã³ã¹ã§ãã</p> -<h2 class=original>User-defined subroutines</h2> +<h2 class="original">User-defined subroutines</h2> <h2>ã¦ã¼ã¶ã¼å®ç¾©ã®ãµãã«ã¼ãã³</h2> -<p class=original>Subroutines are declared using the <code>sub</code> keyword. In contrast with built-in functions, user-defined subroutines always accept the same input: a list of scalars. That list may of course have a single element, or be empty. A single scalar is taken as a list with a single element. A hash with <var>N</var> elements is taken as a list with 2<var>N</var> elements.</p> +<p class="original">Subroutines are declared using the <code>sub</code> keyword. In contrast with built-in functions, user-defined subroutines always accept the same input: a list of scalars. That list may of course have a single element, or be empty. A single scalar is taken as a list with a single element. A hash with <var>N</var> elements is taken as a list with 2<var>N</var> elements.</p> <p>ãµãã«ã¼ãã³ã¯<code>sub</code> ãã¼ã¯ã¼ãã使ã£ã¦å®£è¨ããã¾ããçµè¾¼é¢æ°ã¨å¯¾ç §çã«ãã¦ã¼ã¶ã¼å®ç¾©ã®ãµãã«ã¼ãã³ã¯å¸¸ã«åãå ¥åãåãä»ãã¾ã: ã¹ã«ã©ã®ãªã¹ãã§ãããã®ãªã¹ãã¯ããã¡ãããã²ã¨ã¤ã®è¦ç´ ãã空ã®å ´åãããã¾ããã²ã¨ã¤ã®ã¹ã«ã©ã¯ä¸ã¤ã®è¦ç´ ã®ãªã¹ãã§ãã<var>N</var>è¦ç´ ã®ããã·ã¥ã¯2<var>N</var>è¦ç´ ã®ãªã¹ãã§ãã</p> -<p class=original>Although the brackets are optional, subroutines should always be invoked using brackets, even when called with no arguments. This makes it clear that a subroutine call is happening.</p> +<p class="original">Although the brackets are optional, subroutines should always be invoked using brackets, even when called with no arguments. This makes it clear that a subroutine call is happening.</p> <p>æ¬å¼§ã¯ãªãã·ã§ã³ã§ããããµãã«ã¼ãã³ã¯ãå¼æ°ãã²ã¨ã¤ãç¡ãã¦ãã常ã«æ¬å¼§ä»ãã§ä½¿ãã¹ãã§ãããããã¦ããã°ããµãã«ã¼ãã³ãå¼ã°ãããã¨ããæ確ã«ãªãã¾ãã</p> -<p class=original>Once you're inside a subroutine, the arguments are available using the <a href="http://perldoc.perl.org/perlvar.html">built-in array variable</a> <code>@_</code>. Example:</p> -<p>ãµãã«ã¼ãã³ã®ä¸ã«å ¥ã£ã¦ãã¾ãã¨ã<a href="http://perldoc.perl.org/perlvar.html">çµè¾¼ã®é åå¤æ°</a><code>@_</code>ã使ãã¾ããä¾:</p> +<p class="original">Once you're inside a subroutine, the arguments are available using the <a href="http://perldoc.perl.org/perlvar.html">built-in array variable</a> <code>@_</code>. Example:</p> +<p>ãµãã«ã¼ãã³ã®ä¸ã«å ¥ã£ã¦ãã¾ãã¨ã<a href="http://perldoc.jp/docs/perl/perlvar.pod">çµè¾¼ã®é åå¤æ°</a><code>@_</code>ã使ãã¾ããä¾:</p> <pre class="perl prettyprint"> sub hyphenate { @@ -1179,21 +1179,21 @@ my $word = shift @_; # An overly clever list comprehension - $word = join "-", map { <a href="http://perldoc.perl.org/functions/substr.html">substr</a> $word, $_, 1 } (0 .. (<a href="http://perldoc.perl.org/functions/length.html">length</a> $word) - 1); + $word = join "-", map { <a href="http://perldoc.jp/func/substr">substr</a> $word, $_, 1 } (0 .. (<a href="http://perldoc.jp/func/length">length</a> $word) - 1); return $word; } print hyphenate("exterminate"); # "e-x-t-e-r-m-i-n-a-t-e" </pre> -<h3 class=original>Unpacking arguments</h3> +<h3 class="original">Unpacking arguments</h3> <h3>å¼æ°ãåãåºã</h3> -<p class=original>There's More Than One Way To unpack <code>@_</code>, but some are superior to others.</p> +<p class="original">There's More Than One Way To unpack <code>@_</code>, but some are superior to others.</p> <p><code>@_</code>ãåãåºãã®ã«ããã¤ãããæ¹ãããã¾ãã ã§ãããããã¤ãã¯ãä»ã®ãã®ãããããè¯ãã§ãã</p> -<p class=original>The example subroutine <code>left_pad</code> below pads a string out to the required length using the supplied pad character. (The <code>x</code> function concatenates multiple copies of the same string in a row.) (Note: for brevity, these subroutines all lack some elementary error checking, i.e. ensuring the pad character is only 1 character, checking that the width is greater than or equal to the length of existing string, checking that all needed arguments were passed at all.)</p> +<p class="original">The example subroutine <code>left_pad</code> below pads a string out to the required length using the supplied pad character. (The <code>x</code> function concatenates multiple copies of the same string in a row.) (Note: for brevity, these subroutines all lack some elementary error checking, i.e. ensuring the pad character is only 1 character, checking that the width is greater than or equal to the length of existing string, checking that all needed arguments were passed at all.)</p> <p>ä¾ã®ãµãã«ã¼ãã³<code>left_pad</code>ã¯ã以ä¸ã®ä¾ã¯ã渡ãããè©°ãè¾¼ã¿æåã使ã£ã¦ãå¿ è¦ãªé·ãã«ãªãã¾ã§æååã«ä»å ãã¾ãã(<code>x</code>é¢æ°ã¯è¡ã«åãæååã®è¤æ°ã®ã³ãã¼ãã¤ãªãã¾ã)ã(注æ: ç°¡æ½ãã®ããã«ããããã®ãµãã«ã¼ãã³ã¯å ¨ã¦åºæ¬çãªã¨ã©ã¼ãã§ãã¯ãè¡ã£ã¦ãã¾ãããä¾ãã°ãè©°ãè¾¼ã¿æåã1æåã®ã¿ã§ãããã¨ãä¿è¨¼ããã¨ããé·ããæ¢åã®æååã®é·ã以ä¸ã§ããããå¿ è¦ãªå¼æ°ãå ¨ã¦æ¸¡ããã¦ãããã©ããããªã©)ã</p> -<p class=original><code>left_pad</code> is typically invoked as follows:</p> +<p class="original"><code>left_pad</code> is typically invoked as follows:</p> <p><code>left_pad</code> ã¯å ¸åçã«ã次ã®ããã«å¼ã°ãã¾ã:</p> <pre class="perl prettyprint"> print left_pad("hello", 10, "+"); # "+++++hello" @@ -1201,7 +1201,7 @@ <ol> <li> - <p class=original>Some people don't unpack the arguments at all and use <code>@_</code> "live". This is ugly and discouraged:</p> + <p class="original">Some people don't unpack the arguments at all and use <code>@_</code> "live". This is ugly and discouraged:</p> <p>人ã«ãã£ã¦ã¯ãå¼æ°ãåãåºããã«<code>@_</code>ã"ãã®ã¾ã¾"使ãããããã¾ãããããã¯ãéãã®ã§éæ¨å¥¨ã§ã:</p> <pre class="perl prettyprint"> sub left_pad { @@ -1211,7 +1211,7 @@ </pre> </li> <li> - <p class=original>Unpacking <code>@_</code> is only slightly less strongly discouraged:</p> + <p class="original">Unpacking <code>@_</code> is only slightly less strongly discouraged:</p> <p><code>@_</code>ã®åãåºãã¯ãã»ãã®å°ããã¤ããã®ã¯ãå¼·ãæ¨å¥¨ããã¾ãã:</p> <pre class="perl prettyprint"> sub left_pad { @@ -1224,7 +1224,7 @@ </pre> </li> <li> - <p class=original>Unpacking <code>@_</code> by removing data from it using <code>shift</code> is recommended for up to 4 arguments:</p> + <p class="original">Unpacking <code>@_</code> by removing data from it using <code>shift</code> is recommended for up to 4 arguments:</p> <p><code>@_</code>ãåãåºãã®ã«ã<code>shift</code>ã使ã£ã¦ã@_ãããã¼ã¿ãåé¤ããã®ã¯ãå¼æ°ã4ã¤ã¾ã§ãªãæ¨å¥¨ããã¾ã:</p> <pre class="perl prettyprint"> sub left_pad { @@ -1235,7 +1235,7 @@ return $newString; } </pre> - <p class=original>If no array is provided to the <code>shift</code> function, then it operates on <code>@_</code> implicitly. This approach is seen very commonly:</p> + <p class="original">If no array is provided to the <code>shift</code> function, then it operates on <code>@_</code> implicitly. This approach is seen very commonly:</p> <p><code>shift</code>ã«é åã渡ããªããã°ãæé»ã«ã<code>@_</code>ã«å¯¾ãã¦æä½ãã¾ãããã®ã¢ããã¼ãã¯ã¨ã¦ãããè¦ããã¾ã:</p> <pre class="perl prettyprint"> sub left_pad { @@ -1246,11 +1246,11 @@ return $newString; } </pre> - <p class=original>Beyond 4 arguments it becomes hard to keep track of what is being assigned where.</p> + <p class="original">Beyond 4 arguments it becomes hard to keep track of what is being assigned where.</p> <p>å¼æ°ã5ã¤ä»¥ä¸ã«ãªããªããã©ãã§å²ãå½ã¦ããã追ãç¶ããã®ãé£ãããªãã§ãããã</p> </li> <li> - <p class=original>You can unpack <code>@_</code> all in one go using multiple simultaneous scalar assignment. Again, this is okay for up to 4 arguments:</p> + <p class="original">You can unpack <code>@_</code> all in one go using multiple simultaneous scalar assignment. Again, this is okay for up to 4 arguments:</p> <p><code>@_</code>ã®åãåºãããåæã«å ¨ã¦ä¸åº¦ã«ã¹ã«ã©ã«å²ãå½ã¦ããã¨ãåºæ¥ã¾ãã ãã®æ¹æ³ããå¼æ°ã4ã¤ã¾ã§ãªãåé¡ããã¾ãã:</p> <pre class="perl prettyprint"> sub left_pad { @@ -1261,12 +1261,12 @@ </pre> </li> <li> - <p class=original>For subroutines with large numbers of arguments or where some arguments are optional or cannot be used in combination with others, best practice is to require the user to provide a hash of arguments when calling the subroutine, and then unpack <code>@_</code> back into that hash of arguments. For this approach, our subroutine call would look a little different:</p> + <p class="original">For subroutines with large numbers of arguments or where some arguments are optional or cannot be used in combination with others, best practice is to require the user to provide a hash of arguments when calling the subroutine, and then unpack <code>@_</code> back into that hash of arguments. For this approach, our subroutine call would look a little different:</p> <p>å¼æ°ãå¤ããµãã«ã¼ãã³ããããã¤ãã®å¼æ°ããªãã·ã§ã³ã§ããã¨ããä»ã¨ã®çµã¿åããã§ä½¿ããªããªããæãè¯ãæ¹æ³ã¯ããµãã«ã¼ãã³ã®å¼ã³åºãæã«ãã¦ã¼ã¶ã«ããã·ã¥ã®å¼æ°ã渡ããããã¨ã§ããããã¦ã<code>@_</code>ãããã·ã¥ã«åãåºãã¾ãããã®ã¢ããã¼ãã®ããã«ããµãã«ã¼ãã³ã®å¼ã³åºãã¯ã¡ãã£ã¨éã£ããã®ã«ãªãã¾ã:</p> <pre class="perl prettyprint"> print left_pad("oldString" => "pod", "width" => 10, "padChar" => "+"); </pre> - <p class=original>And the subroutine itself looks like this:</p> + <p class="original">And the subroutine itself looks like this:</p> <p>ããã¦ããµãã«ã¼ãã³èªèº«ã¯æ¬¡ã®ããã«ãªãã¾ã:</p> <pre class="perl prettyprint"> sub left_pad { @@ -1277,9 +1277,9 @@ </pre> </li> </ol> -<h3 class=original>Returning values</h3> +<h3 class="original">Returning values</h3> <h3>æ»ãå¤</h3> -<p class=original>Like other Perl expressions, subroutine calls may display contextual behaviour. You can use the <code>wantarray</code> function (which should be called <code>wantlist</code> but never mind) to detect what context the subroutine is being evaluated in, and return a result appropriate to that context:</p> +<p class="original">Like other Perl expressions, subroutine calls may display contextual behaviour. You can use the <code>wantarray</code> function (which should be called <code>wantlist</code> but never mind) to detect what context the subroutine is being evaluated in, and return a result appropriate to that context:</p> <p>ä»ã®Perlã®å¼ã¨åæ§ããµãã«ã¼ãã³å¼ã³åºãã¯ãã³ã³ããã¹ãä¾åã®æ¯ãèãããã¾ãã<code>wantlist</code>(<code>wantlist</code>ã¨å¼ã°ããã¹ãã§ãããæ°ã«ããªãã§ãã ãã)ã使ã£ã¦ãã©ã®ã³ã³ããã¹ãã§ãµãã«ã¼ãã³ãè©ä¾¡ããã¦ãããããã§ãã¯ã§ããã³ã³ããã¹ãã«é©ããçµæãè¿ããã¨ãåºæ¥ã¾ã:</p> @@ -1303,9 +1303,9 @@ <p class="original">Apologies if you already know the following non-Perl-related facts. Every time a process finishes on a Windows or Linux system (and, I assume, on most other systems), it concludes with a 16-bit <i>status word</i>. The highest 8 bits constitute a <i>return code</i> between 0 and 255 inclusive, with 0 conventionally representing unqualified success, and other values representing various degrees of failure. The other 8 bits are less frequently examined - they "reflect mode of failure, like signal death and core dump information".</p> <p>æ¢ã«ä»¥ä¸ã®Perlã¨é¢ä¿ãªãäºå®ããåç¥ã§ãããç³ã訳æãã¾ãããWindowãLinux(ã¾ããå¤ãã®ä»ã®ã·ã¹ãã ã§ãåæ§ã¨æ³å®ããã¾ãã)ã®ã·ã¹ãã ã§ã¯ããã»ã¹ãçµãããã³ã«ã16ãããã®<i>ç¶æ ã¯ã¼ã</i>ã§çµäºãã¾ããä¸ä½ã®8ãããã¯0ã255ã®éãå«ã<i>ãªã¿ã¼ã³ã³ã¼ã</i>ãæ§æãã¾ãã0ã¯æ £ä¾çã«ãç¡æ¡ä»¶ã§æåãããã¨ã示ãã¾ããä»ã®å¤ã¯æ§ã ãªåº¦åãã®å¤±æã示ãã¾ããä»ã®8ãããã¯ãã¾ããã調ã¹ããã¾ãããããããã¯"ã·ã°ãã«ã®æ»äº¡ãã³ã¢ãã³ãã®æ å ±ã®ãããªå¤±æã®ã¢ã¼ããåæ ãã¾ã"ã</p> <p class="original">You can exit from a Perl script with the return code of your choice (from 0 to 255) using <code><a href="http://perldoc.perl.org/functions/exit.html">exit</a></code>.</p> -<p>Perlããçµäºããéã«ã<code><a href="http://perldoc.perl.org/functions/exit.html">exit</a></code>ã使ã£ã¦(0ãã255ã¾ã§ã®)好ããªãªã¿ã¼ã³ã³ã¼ããè¿ãã¾ãã</p> +<p>Perlããçµäºããéã«ã<code><a href="http://perldoc.jp/func/exit">exit</a></code>ã使ã£ã¦(0ãã255ã¾ã§ã®)好ããªãªã¿ã¼ã³ã³ã¼ããè¿ãã¾ãã</p> <p class="original">Perl provides More Than One Way To - in a single call - spawn a child process, pause the current script until the child process has finished, and then resume interpretation of the current script. Whichever method is used, you will find that immediately afterwards, the <a href="http://perldoc.perl.org/perlvar.html">built-in scalar variable</a> <code>$?</code> has been populated with the status word that was returned from that child process's termination. You can get the return code by taking just the highest 8 of those 16 bits: <code>$? >> 8</code>.</p> -<p>Perlã«ã¯ä¸ã¤ä»¥ä¸ã® - åããã»ã¹ãç£ã - æ¹æ³ãããã¾ããç¾å¨ã®ã¹ã¯ãªãããæ¢ããåããã»ã¹ãçµãã£ãããç¾å¨ã®ã¹ã¯ãªããã®è§£éãç¶ãã¾ããã©ã®æ¹æ³ã使ã£ã¦ãããã®ç´å¾ã§ãåããã»ã¹ã®çµäºæã«è¿ãããç¶æ ã¯ã¼ãã<a href="http://perldoc.perl.org/perlvar.html">çµè¾¼ã®ã¹ã«ã©å¤æ°</a>ã®<code>$?</code>ã«å ¥ãã¾ããè¿ãããå¤ã®16ãããã®ä¸ä½8ãåããã¨ã§ããªã¿ã¼ã³ã³ã¼ããå¾ããã¨ãã§ãã¾ã: <code>$? >> 8</code>ã</p> +<p>Perlã«ã¯ä¸ã¤ä»¥ä¸ã® - åããã»ã¹ãç£ã - æ¹æ³ãããã¾ããç¾å¨ã®ã¹ã¯ãªãããæ¢ããåããã»ã¹ãçµãã£ãããç¾å¨ã®ã¹ã¯ãªããã®è§£éãç¶ãã¾ããã©ã®æ¹æ³ã使ã£ã¦ãããã®ç´å¾ã§ãåããã»ã¹ã®çµäºæã«è¿ãããç¶æ ã¯ã¼ãã<a href="http://perldoc.jp/docs/perl/perlvar.pod">çµè¾¼ã®ã¹ã«ã©å¤æ°</a>ã®<code>$?</code>ã«å ¥ãã¾ããè¿ãããå¤ã®16ãããã®ä¸ä½8ãåããã¨ã§ããªã¿ã¼ã³ã³ã¼ããå¾ããã¨ãã§ãã¾ã: <code>$? >> 8</code>ã</p> <p class="original">The <code>system</code> function can be used to invoke another program with the arguments listed. The value returned by <code>system</code> is the same value with which <code>$?</code> is populated:</p> <p><code>system</code>é¢æ°ã¯ä»ã®ããã°ã©ã ãå¼æ°ã®ãªã¹ãã¨ä¸ç·ã«å¼ã³åºãã¾ãã<code>system</code>ã«ãã£ã¦è¿ãããå¤ã¯ã<code>$?</code>ã«å ¥ãã®ã¨åãå¤ã§ã:</p> <pre class="perl prettyprint"> @@ -1332,11 +1332,11 @@ <h2 class="original">Files and file handles</h2> <h2>ãã¡ã¤ã«ã¨ãã¡ã¤ã«ãã³ãã«</h2> -<p class=original>A scalar variable may contain a <i>file handle</i> instead of a number/string/reference or <code>undef</code>. A file handle is essentially a reference to a specific location inside a specific file.</p> +<p class="original">A scalar variable may contain a <i>file handle</i> instead of a number/string/reference or <code>undef</code>. A file handle is essentially a reference to a specific location inside a specific file.</p> <p>ã¹ã«ã©å¤æ°ã¯ãæ°å/æåå/ãªãã¡ã¬ã³ã¹ã<code>undef</code>ã®ä»£ããã«<i>ãã¡ã¤ã«ãã³ãã«</i>ãæã¦ã¾ãããã¡ã¤ã«ãã³ãã«ã¯åºæ¬çã«ç¹å®ã®ãã¡ã¤ã«ã®ç¹å®ã®å ´æã示ããªãã¡ã¬ã³ã¹ã§ãã</p> -<p class=original>Use <code><a href="http://perldoc.perl.org/functions/open.html">open</a></code> to turn a scalar variable into a file handle. <code>open</code> must be supplied with a <i>mode</i>. The mode <code><</code> indicates that we wish to open the file to read from it:</p> -<p><code><a href="http://perldoc.perl.org/functions/open.html">open</a></code>ã使ã£ã¦ãã¹ã«ã©å¤æ°ããã¡ã¤ã«ãã³ãã«ã«ãã¾ãã<code>open</code>ã¯<i>ã¢ã¼ã</i>ã¨ã¨ãã«ä½¿ãããªããã°ããã¾ãããã¢ã¼ã <code><</code> ã¯ããã¡ã¤ã«ããèªã¿åºããããã¨ãæå³ãã¾ã:</p> +<p class="original">Use <code><a href="http://perldoc.perl.org/functions/open.html">open</a></code> to turn a scalar variable into a file handle. <code>open</code> must be supplied with a <i>mode</i>. The mode <code><</code> indicates that we wish to open the file to read from it:</p> +<p><code><a href="http://perldoc.jp/func/open">open</a></code>ã使ã£ã¦ãã¹ã«ã©å¤æ°ããã¡ã¤ã«ãã³ãã«ã«ãã¾ãã<code>open</code>ã¯<i>ã¢ã¼ã</i>ã¨ã¨ãã«ä½¿ãããªããã°ããã¾ãããã¢ã¼ã <code><</code> ã¯ããã¡ã¤ã«ããèªã¿åºããããã¨ãæå³ãã¾ã:</p> <pre class="perl prettyprint"> my $f = "text.txt"; @@ -1356,8 +1356,8 @@ <p class="original">Note the need for parentheses around the <code>open</code> call's arguments.</p> <p><code>open</code>å¼ã³åºãã®å¼æ°ã«æ¬å¼§ãå¿ è¦ãªãã¨ã«æ³¨æãã¦ãã ããã</p> -<p class=original>To read a line of text from a filehandle, use the <code><a href="http://perldoc.perl.org/functions/readline.html">readline</a></code> built-in function. <code>readline</code> returns a full line of text, with a line break intact at the end of it (except possibly for the final line of the file), or <code>undef</code> if you've reached the end of the file.</p> -<p>ãã¡ã¤ã«ãã³ãã«ããããã¹ãã®è¡ãèªãããã«ãçµè¾¼é¢æ°ã®<code><a href="http://perldoc.perl.org/functions/readline.html">readline</a></code>ã使ãã¾ãã<code>readline</code>ã¯ãããã¹ãã®ä¸è¡å ¨ä½ãããã®çµããã«æ¹è¡ããã®ã¾ã¾å«ãã§è¿ã(ãã¶ããã¡ã¤ã«ã®æçµè¡ãé¤ãã¦)ãããã¡ã¤ã«ã®æå¾ã«éããã¨<code>undef</code>ãè¿ãã¾ãã</p> +<p class="original">To read a line of text from a filehandle, use the <code><a href="http://perldoc.perl.org/functions/readline.html">readline</a></code> built-in function. <code>readline</code> returns a full line of text, with a line break intact at the end of it (except possibly for the final line of the file), or <code>undef</code> if you've reached the end of the file.</p> +<p>ãã¡ã¤ã«ãã³ãã«ããããã¹ãã®è¡ãèªãããã«ãçµè¾¼é¢æ°ã®<code><a href="http://perldoc.jp/func/readline">readline</a></code>ã使ãã¾ãã<code>readline</code>ã¯ãããã¹ãã®ä¸è¡å ¨ä½ãããã®çµããã«æ¹è¡ããã®ã¾ã¾å«ãã§è¿ã(ãã¶ããã¡ã¤ã«ã®æçµè¡ãé¤ãã¦)ãããã¡ã¤ã«ã®æå¾ã«éããã¨<code>undef</code>ãè¿ãã¾ãã</p> <pre class="perl prettyprint"> while(1) { @@ -1367,7 +1367,7 @@ } </pre> <p class="original">To truncate that possible trailing line break, use <code><a href="http://perldoc.perl.org/functions/chomp.html">chomp</a></code>:</p> -<p><code><a href="http://perldoc.perl.org/functions/chomp.html">chomp</a></code>ã使ãã¨æ¹è¡ãåãé¤ãã¾ã:</p> +<p><code><a href="http://perldoc.jp/func/chomp">chomp</a></code>ã使ãã¨æ¹è¡ãåãé¤ãã¾ã:</p> <pre class="perl prettyprint"> chomp $line; </pre> @@ -1375,7 +1375,7 @@ <p><code>chomp</code>㯠<code>$line</code>ã«å¯¾ãã¦ãã®å ´ã§åãã¾ãã<code>$line = chomp $line</code>ã¯å¤åãæã¿ã®ãã®ã§ã¯ãªãã§ãããã</p> <p class="original">You can also use <code><a href="http://perldoc.perl.org/functions/eof.html">eof</a></code> to detect that the end of the file has been reached:</p> -<p><code><a href="http://perldoc.perl.org/functions/eof.html">eof</a></code>ã使ã£ã¦ãã¡ã¤ã«ã®çµç«¯ãå¤æãããã¨ãã§ãã¾ã:</p> +<p><code><a href="http://perldoc.jp/func/eof">eof</a></code>ã使ã£ã¦ãã¡ã¤ã«ã®çµç«¯ãå¤æãããã¨ãã§ãã¾ã:</p> <pre class="perl prettyprint"> while(!eof $fh) { my $line = readline $fh; @@ -1406,11 +1406,11 @@ <p class="original">Notice the absence of a comma between <code>$fh2</code> and the next argument.</p> <p><code>print</code>ã§<code>$fh2</code>ã¨æ¬¡ã®å¼æ°ã®éã«ã«ã³ãããªããã¨ã«æ°ãã¤ãã¦ãã ããã</p> -<p class=original>File handles are actually closed automatically when they drop out of scope, but otherwise:</p> +<p class="original">File handles are actually closed automatically when they drop out of scope, but otherwise:</p> <p>ãã¡ã¤ã«ãã³ãã«ã¯ã¹ã³ã¼ããæããã¨èªåçã«éãããã¾ãããããã¯ã次ã®ããã«ãã¾ã:</p> <pre class="perl prettyprint"> -<a href="http://perldoc.perl.org/functions/close.html">close</a> $fh2; +<a href="http://perldoc.jp/func/close">close</a> $fh2; close $fh; </pre> @@ -1429,20 +1429,20 @@ <p class="original">As you may have gathered, <code>print</code> prints to <code>STDOUT</code> by default if no filehandle is named.</p> <p>åãããã¨æãã¾ããã<code>print</code>ã¯ããã¡ã¤ã«ãã³ãã«ãçç¥ãããå ´åã¯ãããã©ã«ãã§<code>STDOUT</code>ã«åºåãã¾ããã</p> -<h3 class=original>File tests</h3> +<h3 class="original">File tests</h3> <h3>ãã¡ã¤ã«ãã¹ã</h3> -<p class=original>The function <code>-e</code> is a built-in function which tests whether the named file exists.</p> +<p class="original">The function <code>-e</code> is a built-in function which tests whether the named file exists.</p> <p>é¢æ°<code>-e</code> ã¯çµè¾¼ã®é¢æ°ã§ä¸ããããååã®ãã¡ã¤ã«ãåå¨ãããã©ããããã¹ããã¾ãã</p> <pre class="perl prettyprint"> print "what" unless -e "/usr/bin/perl"; </pre> -<p class=original>The function <code>-d</code> is a built-in function which tests whether the named file is a directory.</p> +<p class="original">The function <code>-d</code> is a built-in function which tests whether the named file is a directory.</p> <p>é¢æ°<code>-d</code> ã¯çµè¾¼ã®é¢æ°ã§ä¸ããããååã®ãã¡ã¤ã«ããã£ã¬ã¯ããªãã©ããããã¹ããã¾ãã</p> -<p class=original>The function <code>-f</code> is a built-in function which tests whether the named file is a plain file.</p> +<p class="original">The function <code>-f</code> is a built-in function which tests whether the named file is a plain file.</p> <p>é¢æ°<code>-f</code> ã¯çµè¾¼ã®é¢æ°ã§ä¸ããããååã®ãã¡ã¤ã«ãæ®éã®ãã¡ã¤ã«ãã©ããããã¹ããã¾ãã</p> -<p class=original>These are just three of <a href="http://perldoc.perl.org/functions/-X.html">a large class of functions</a> of the form <code>-X</code> where <code>X</code> is some lower- or upper-case letter. These functions are called <i>file tests</i>. Note the leading minus sign. In a Google query, the minus sign indicates to exclude results containing this search term. This makes file tests hard to Google for! Just search for "perl file test" instead.</p> -<p><code>-X</code>å½¢å¼ã®<a href="http://perldoc.perl.org/functions/-X.html">大ããªã¯ã©ã¹ã®é¢æ°</a>ã®3ã¤ã®é¢æ°ã§ãã<code>X</code>ã¯å°æåã大æåã§ãããããã®é¢æ°ã¯<i>ãã¡ã¤ã«ãã¹ã</i>ã¨å¼ã°ãã¾ãããã¤ãã¹è¨å·ãå ã«æ¥ããã¨ã«æ°ãã¤ãã¦ãã ãããGoogleã¯ã¨ãªã§ã¯ããã¤ãã¹è¨å·ã¯ããã®è¨èãçµæã«å«ããªããã¨ãæ示ãã¾ãããã®ããããã¡ã¤ã«ãã¹ããGoogleã§æ¤ç´¢ãã¥ãããã¦ãã¾ã! 代ããã«ã "perl file test"(訳註: "perl ãã¡ã¤ã«ãã¹ã")ã§æ¤ç´¢ãã¦ä¸ããã</p> +<p class="original">These are just three of <a href="http://perldoc.perl.org/functions/-X.html">a large class of functions</a> of the form <code>-X</code> where <code>X</code> is some lower- or upper-case letter. These functions are called <i>file tests</i>. Note the leading minus sign. In a Google query, the minus sign indicates to exclude results containing this search term. This makes file tests hard to Google for! Just search for "perl file test" instead.</p> +<p><code>-X</code>å½¢å¼ã®<a href="http://perldoc.jp/func/-X">大ããªã¯ã©ã¹ã®é¢æ°</a>ã®3ã¤ã®é¢æ°ã§ãã<code>X</code>ã¯å°æåã大æåã§ãããããã®é¢æ°ã¯<i>ãã¡ã¤ã«ãã¹ã</i>ã¨å¼ã°ãã¾ãããã¤ãã¹è¨å·ãå ã«æ¥ããã¨ã«æ°ãã¤ãã¦ãã ãããGoogleã¯ã¨ãªã§ã¯ããã¤ãã¹è¨å·ã¯ããã®è¨èãçµæã«å«ããªããã¨ãæ示ãã¾ãããã®ããããã¡ã¤ã«ãã¹ããGoogleã§æ¤ç´¢ãã¥ãããã¦ãã¾ã! 代ããã«ã "perl file test"(訳註: "perl ãã¡ã¤ã«ãã¹ã")ã§æ¤ç´¢ãã¦ä¸ããã</p> <h2 class="original">Regular expressions</h2> <h2>æ£è¦è¡¨ç¾</h2> @@ -1535,17 +1535,17 @@ # returns true </pre> -<h2 class=original>Modules and packages</h2> +<h2 class="original">Modules and packages</h2> <h2>ã¢ã¸ã¥ã¼ã«ã¨ããã±ã¼ã¸</h2> <p class="original">In Perl, modules and packages are different things.</p> <p>Perlã«ããã¦ãã¢ã¸ã¥ã¼ã«ã¨ããã±ã¼ã¸ã¯å¥ç©ã§ãã</p> -<h3 class=original>Modules</h3> +<h3 class="original">Modules</h3> <h3>ã¢ã¸ã¥ã¼ã«</h3> -<p class=original>A <i>module</i> is a <code>.pm</code> file that you can include in another Perl file (script or module). A module is a text file with exactly the same syntax as a <code>.pl</code> Perl script. An example module might be located at <code>C:\foo\bar\baz\Demo\StringUtils.pm</code> or <code>/foo/bar/baz/Demo/StringUtils.pm</code>, and read as follows:</p> +<p class="original">A <i>module</i> is a <code>.pm</code> file that you can include in another Perl file (script or module). A module is a text file with exactly the same syntax as a <code>.pl</code> Perl script. An example module might be located at <code>C:\foo\bar\baz\Demo\StringUtils.pm</code> or <code>/foo/bar/baz/Demo/StringUtils.pm</code>, and read as follows:</p> <p>A <i>ã¢ã¸ã¥ã¼ã«</i>ã¯ãä»ã®Perlãã¡ã¤ã«(ã¹ã¯ãªãããã¢ã¸ã¥ã¼ã«)ã«å«ãããã¨ãåºæ¥ã<code>.pm</code>ãã¡ã¤ã«ã§ããã¢ã¸ã¥ã¼ã«ã¯ <code>.pl</code> Perlã¹ã¯ãªããã¨ã¾ã£ããåãã·ã³ã¿ãã¯ã®ã¹ããã¹ããã¡ã¤ã«ã§ããä¾ã®ã¢ã¸ã¥ã¼ã«ã¯ã<code>C:\foo\bar\baz\Demo\StringUtils.pm</code> ã <code>/foo/bar/baz/Demo/StringUtils.pm</code>ã«ããã¾ããç¶ããèªãã§ãã ãã:</p> <pre class="perl prettyprint"> use strict; @@ -1560,22 +1560,22 @@ return 1; </pre> -<p class=original>Because a module is executed from top to bottom when it is loaded, you need to return a true value at the end to show that it was loaded successfully.</p> +<p class="original">Because a module is executed from top to bottom when it is loaded, you need to return a true value at the end to show that it was loaded successfully.</p> <p>ã¢ã¸ã¥ã¼ã«ã¯ãã¼ããããã¨ãæåããæå¾ã¾ã§å®è¡ãããã®ã§ããã¼ããæåãããã¨ã示ãããã«ãæå¾ã«çã®å¤ãè¿ãå¿ è¦ãããã¾ãã</p> -<p class=original>So that the Perl interpreter can find them, directories containing Perl modules should be listed in your environment variable <code>PERL5LIB</code> beforehand. List the root directory containing the modules, don't list the module directories or the modules themselves:</p> +<p class="original">So that the Perl interpreter can find them, directories containing Perl modules should be listed in your environment variable <code>PERL5LIB</code> beforehand. List the root directory containing the modules, don't list the module directories or the modules themselves:</p> <p>Perlã¤ã³ã¿ã¼ããªã¿ã¯ããããè¦ã¤ãããã¨ãã§ããããã«ã¯ããã®åã«ãPerlã¢ã¸ã¥ã¼ã«ãå ¥ã£ã¦ãããã£ã¬ã¯ããªããç°å¢å¤æ°<code>PERL5LIB</code>ã«ãªã¹ãããã¦ããã¹ãã§ããã¢ã¸ã¥ã¼ã«ãå ¥ã£ã¦ããã«ã¼ããã£ã¬ã¯ããªããªã¹ããã¦ãã ãããã¢ã¸ã¥ã¼ã«ã®ãã£ã¬ã¯ããªãã¢ã¸ã¥ã¼ã«èªèº«ããªã¹ããã¦ã¯ããã¾ããã</p> <pre class="bash"> set PERL5LIB=C:\foo\bar\baz;%PERL5LIB% </pre> -<p class=original>or</p> +<p class="original">or</p> <p>ã¾ãã¯</p> <pre class="bash"> export PERL5LIB=/foo/bar/baz:$PERL5LIB </pre> -<p class=original>Once the Perl module is created and <code>perl</code> knows where to look for it, you can use the <code>require</code> built-in function to search for and execute it during a Perl script. For example, calling <code>require Demo::StringUtils</code> causes the Perl interpreter to search each directory listed in <code>PERL5LIB</code> in turn, looking for a file called <code>Demo/StringUtils.pm</code>. 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 <code>main.pl</code> and read as follows:</p> +<p class="original">Once the Perl module is created and <code>perl</code> knows where to look for it, you can use the <code>require</code> built-in function to search for and execute it during a Perl script. For example, calling <code>require Demo::StringUtils</code> causes the Perl interpreter to search each directory listed in <code>PERL5LIB</code> in turn, looking for a file called <code>Demo/StringUtils.pm</code>. 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 <code>main.pl</code> and read as follows:</p> <p>Perlã¢ã¸ã¥ã¼ã«ãä½ããã¦ã<code>perl</code>ããããã©ãã«ããããç¥ã£ã¦ããã°ãçµè¾¼ã®<code>require</code>é¢æ°ã使ã£ã¦æ¢ããPerlã®ã¹ã¯ãªããä¸ã§å®è¡ãããã¨ãã§ãã¾ããä¾ãã°ã<code>require Demo::StringUtils</code>ãå¼ã¶ã¨ãPerlã¤ã³ã¿ã¼ããªã¿ã¯<code>PERL5LIB</code>ã«ãªã¹ãããã¦ãããã£ã¬ã¯ããªãé çªã«ã <code>Demo/StringUtils.pm</code>ã¨ãããã¡ã¤ã«ãæ¢ãã¾ããã¢ã¸ã¥ã¼ã«ããã¼ããããããçªç¶ã«ãµãã«ã¼ãã³ã¨å¤æ°ãã¡ã¤ã³ã¹ã¯ãªããã«å®ç¾©ããã¾ãããã®ä¾ã®ã¹ã¯ãªããã<code>main.pl</code>ã¨å¼ã³ã¾ããããç¶ãã¦èªãã§ããã:</p> <pre class="perl prettyprint"> @@ -1593,10 +1593,10 @@ <p class="original">Now a problem surfaces: if <code>main.pl</code> contains many <code>require</code> calls, and each of the modules so loaded contains more <code>require</code> calls, then it can become difficult to track down the original declaration of the <code>zombify</code> subroutine. The solution to this problem is to use packages.</p> <p>ããã§åé¡ã表é¢åãã¾ã: <code>main.pl</code>ããå¤ãã®<code>require</code> ãå¼ãã§ãã¦ãããããã®ã¢ã¸ã¥ã¼ã«ãããã«<code>require</code>ãå¼ãã§ããå ´åã<code>zombify</code>ãµãã«ã¼ãã³ã®å ã®å®£è¨ãã©ãã«ããã®ãã追ãã«ãããªãã¾ãããã®è§£æ±ºçã¨ãã¦ã¯ãããã±ã¼ã¸ã使ããã¨ã§ãã</p> -<h3 class=original>Packages</h3> +<h3 class="original">Packages</h3> <h3>ããã±ã¼ã¸</h3> -<p class=original>A <i>package</i> is a namespace in which subroutines can be declared. Any subroutine you declare is implicitly declared within the current package. At the beginning of execution, you are in the <code>main</code> package, but you can switch package using the <code>package</code> built-in function:</p> +<p class="original">A <i>package</i> is a namespace in which subroutines can be declared. Any subroutine you declare is implicitly declared within the current package. At the beginning of execution, you are in the <code>main</code> package, but you can switch package using the <code>package</code> built-in function:</p> <p><i>package</i>ã¯åå空éã§ããã®ä¸ã§ããµãã«ã¼ãã³ã宣è¨ã§ãã¾ãã宣è¨ãããµãã«ã¼ãã³ã¯ãæé»çã«ãç¾å¨ã®ããã±ã¼ã¸å ã«å®£è¨ããã¾ããå®è¡ã®æåã¯ã<code>main</code>ããã±ã¼ã¸ã«ãªãã¾ãããçµè¾¼é¢æ°ã®<code>package</code>ã使ã£ã¦ãããã±ã¼ã¸ãåãæ¿ãããã¾ã:</p> <pre class="perl prettyprint"> @@ -1657,14 +1657,14 @@ print <ins>Demo::StringUtils::</ins>zombify("i want brains"); # "r wrnt brrrns" </pre> -<p class=original>Now read this next bit carefully.</p> +<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 <code>require Foo::Bar</code> <em>does not</em> look for and load a file with a <code>package Foo::Bar</code> declaration somewhere inside it, nor does it necessarily load subroutines in the <code>Foo::Bar</code> namespace. Calling <code>require Foo::Bar</code> merely loads a file called <code>Foo/Bar.pm</code>, which need not have <em>any</em> kind of package declaration inside it at all, and in fact might declare <code>package Baz::Qux</code> and other nonsense inside it for all you know.</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 <code>require Foo::Bar</code> <em>does not</em> look for and load a file with a <code>package Foo::Bar</code> declaration somewhere inside it, nor does it necessarily load subroutines in the <code>Foo::Bar</code> namespace. Calling <code>require Foo::Bar</code> merely loads a file called <code>Foo/Bar.pm</code>, which need not have <em>any</em> kind of package declaration inside it at all, and in fact might declare <code>package Baz::Qux</code> and other nonsense inside it for all you know.</p> <p>ããã±ã¼ã¸ã¨ã¢ã¸ã¥ã¼ã«ã®2ã¤ã¯ãããã°ã©ãã³ã°è¨èªPerlã«ããã¦å®å ¨ã«åããã¦ãããåºå¥ãããæ©è½ã§ãããã®2ã¤ãåãããã«ã³ãã³ã®ããªãã¿ã使ã£ã¦ãããã¨ã¯ãéè¦ãªã²ã£ããã§ããããã¯ãã¹ã¯ãªããã¾ãã¯ã¢ã¸ã¥ã¼ã«ã®ã³ã¼ã¹çµç±ã§ããã±ã¼ã¸ãè¤æ°ååãæ¿ãããã¨ãã§ããã¾ããè¤æ°ã®ãã¡ã¤ã«å ã®è¤æ°ã®å ´æã§åä¸ã®ããã±ã¼ã¸å®£è¨ã使ããã¨ãã§ãã¾ãã<code>require Foo::Bar</code>ãå¼ã¶ãã¨ã¯<code>Foo::Bar</code>åå空éã«ãããµãã«ã¼ãã³ãããã±ã¼ã¸å¤æ°ãå¿ ããããã¼ã<em>ãã¾ãã</em>ãã<code>Foo::Bar</code>åå空éã®ãµãã«ã¼ãã³ãå¿ ããããã¼ãããããã§ã¯ããã¾ããã<code>require Foo::Bar</code>ãå¼ã¶ãã¨ã¯ãåã«<code>Foo/Bar.pm</code>ã¨ãããã¡ã¤ã«ããã¼ãããã ãã§ããããã®ãã¡ã¤ã«ã«ã<em>ã©ã®ãããª< /em>種é¡ã®ããã±ã¼ã¸å®£è¨ãå¿ è¦æãã¾ãããå®éã«ã¯ã<code>package Baz::Qux</code>ã®ãããªãã³ã»ã³ã¹ãªå®£è¨ãã§ãã¾ãã</p> -<p class=original>Likewise, a subroutine call <code>Baz::Qux::processThis()</code> need not necessarily have been declared inside a file named <code>Baz/Qux.pm</code>. It could have been declared <em>literally anywhere</em>.</p> +<p class="original">Likewise, a subroutine call <code>Baz::Qux::processThis()</code> need not necessarily have been declared inside a file named <code>Baz/Qux.pm</code>. It could have been declared <em>literally anywhere</em>.</p> <p>ãã®ä¸ã<code>Baz::Qux::processThis()</code>ã®ãµãã«ã¼ãã³å¼ã³åºãã¯ã<code>Baz/Qux.pm</code>ã¨ããååã®ãã¡ã¤ã«å ã«å®£è¨ããã¦ããå¿ è¦ããããã¾ããã<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 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 (<code>.pl</code> file) must always contain exactly zero <code>package</code> declarations.</strong></li> @@ -1764,7 +1764,7 @@ <h3 class="original">Constructors</h3> <h3>ã³ã³ã¹ãã©ã¯ã¿</h3> -<p class=original>A constructor is a class method which returns a new object. If you want one, just declare one. You can use any name you like. For class methods, the first argument passed is not an object but a class name. In this case, <code>"Animal"</code>:</p> +<p class="original">A constructor is a class method which returns a new object. If you want one, just declare one. You can use any name you like. For class methods, the first argument passed is not an object but a class name. In this case, <code>"Animal"</code>:</p> <p>ã³ã³ã¹ãã©ã¯ã¿ã¯ã¯ã©ã¹ã¡ã½ããã§ãæ°ãããªãã¸ã§ã¯ããè¿ãã¾ããã³ã³ã¹ãã©ã¯ã¿ã欲ãããã°ãããã宣è¨ããã ãã§ãã好ããªååã使ãã¾ããã¯ã©ã¹ã¡ã½ããã«ã¯ãæåã®å¼æ°ã¨ãã¦ããªãã¸ã§ã¯ãã§ã¯ãªãã¯ã©ã¹åã渡ãã¾ãããã®ã±ã¼ã¹ã§ã¯ã<code>"Animal"</code>ã§ã:</p> <pre class="perl prettyprint"> use strict; @@ -1780,7 +1780,7 @@ # ...etc. </pre> -<p class=original>And then use it like so:</p> +<p class="original">And then use it like so:</p> <p>次ã®ããã«ä½¿ãã¾ã:</p> <pre class="perl prettyprint"> my $animal = Animal->new(); @@ -1908,7 +1908,7 @@ <p class="original">The most common way to define an <code>import()</code> method is to inherit it from the <a href="http://perldoc.perl.org/Exporter.html">Exporter</a> module. Exporter is a core module, and a <i>de facto</i> core feature of the Perl programming language. In Exporter's implementation of <code>import()</code>, the list of arguments that you pass in is interpreted as a list of subroutine names. When a subroutine is <code>import()</code>ed, it becomes available in the current package as well as in its own original package.</p></p> -<p><code>import()</code>ã¡ã½ãããå®ç¾©ãã常èçãªæ¹æ³ã¯ Exporter ã¢ã¸ã¥ã¼ã«ããç¶æ¿ãããã¨ã§ããExporter ã¯ã³ã¢ã¢ã¸ã¥ã¼ã«ã§ãããã°ã©ãã³ã°è¨èªPerlã®<i>ããã¡ã¯ã</i>ã®ã³ã¢ã®æ©è½ã§ããExporterã®<code>import</code>ã®å®è£ ã§ã渡ããå¼æ°ã®ãªã¹ãã¯ããµãã«ã¼ãã³ã®ååã¨ãã¦è§£éããã¾ãããµãã«ã¼ãã³ã<code>import()</code>ãããã¨ãç¾å¨ã®åå空éã§ããã®ãªãªã¸ãã«ã®åå空éã«ãããã®ã¨åãããã«ãå©ç¨å¯è½ã«ãªãã¾ãã</p> +<p><code>import()</code>ã¡ã½ãããå®ç¾©ãã常èçãªæ¹æ³ã¯ <a href="http://perldoc.perl.org/Exporter.html">Exporter</a> ã¢ã¸ã¥ã¼ã«ããç¶æ¿ãããã¨ã§ããExporter ã¯ã³ã¢ã¢ã¸ã¥ã¼ã«ã§ãããã°ã©ãã³ã°è¨èªPerlã®<i>ããã¡ã¯ã</i>ã®ã³ã¢ã®æ©è½ã§ããExporterã®<code>import</code>ã®å®è£ ã§ã渡ããå¼æ°ã®ãªã¹ãã¯ããµãã«ã¼ãã³ã®ååã¨ãã¦è§£éããã¾ãããµãã«ã¼ãã³ã<code>import()</code>ãããã¨ãç¾å¨ã®åå空éã§ããã®ãªãªã¸ãã«ã®åå空éã«ãããã®ã¨åãããã«ãå©ç¨å¯è½ã«ãªãã¾ãã</p> <p class="original">This concept is easiest to grasp using an example. Here's what <code>Caterpillar.pm</code> looks like:</p> <p>ãã®ã³ã³ã»ããã¯ä¾ã使ãã¨ææ¡ããããã§ãããã<code>Caterpillar.pm</code>ã¯æ¬¡ã®ãããªãã®ã§ã:</p> @@ -1954,7 +1954,7 @@ <p class="original">The package variable <code>@EXPORT</code> can be populated with a list of subroutines to be exported by default. These are exported if <code>import()</code> is called with no arguments at all, which is what happens in this example.</p> <p>ããã±ã¼ã¸å¤æ°<code>@EXPORT</code>ã¯ããã©ã«ãã§ã¨ã¯ã¹ãã¼ãããããµãã«ã¼ãã³ã®ãªã¹ããå ¥ãã¾ãã<code>import()</code> ãå¼æ°ãªãã§å¼ã°ããå ´åã«ããã®ä¾ã§èµ·ãããã¨ãèµ·ãã¾ãã</p> -<p class=original>>As a result of being <code>import()</code>ed, a method such as <code>Caterpillar::crawl()</code> become available without qualification as <code>crawl()</code>. This saves typing. (Note: regardless of the content of <code>@EXPORT_OK</code>, every method can always be called "longhand", as shown above. There are no private methods in Perl. Customarily, a method intended for private use is named with a leading underscore or two.)</p> +<p class="original">>As a result of being <code>import()</code>ed, a method such as <code>Caterpillar::crawl()</code> become available without qualification as <code>crawl()</code>. This saves typing. (Note: regardless of the content of <code>@EXPORT_OK</code>, every method can always be called "longhand", as shown above. There are no private methods in Perl. Customarily, a method intended for private use is named with a leading underscore or two.)</p> <p><code>import()</code>ãããçµæã¨ãã¦ã<code>Caterpillar::crawl()</code>ã®ãããªã¡ã½ããã<code>crawl()</code>ã®ããã«ã修飾ãªãã«å©ç¨å¯è½ã«ãªãã¾ããããã¯ãã¿ã¤ãæ°ã®ç¯ç´ã«ãªãã¾ãã(注æ: <code>@EXPORT_OK</code>ã®ã³ã³ã»ããã«ãããããã å ¨ã¦ã®ã¡ã½ããã¯ãä¸ã§è¦ãããã«ã"longhand"ã§å¼ã¶ãã¨ãåºæ¥ã¾ãã Perlã«ã¯ãã©ã¤ãã¼ãã¡ã½ããã¯ããã¾ãããéä¾ã1ã¤ã2ã¤ã®ã¢ã³ãã¼ã¹ã³ã¢ããå§ã¾ãååãä»ããããã¡ã½ããã¯ãã©ã¤ãã¼ããæå³ãã¾ãã</p> @@ -1985,7 +1985,7 @@ use Account qw{create open close suspend delete}; </pre> <p class="original">There are <a href="http://perldoc.perl.org/perlop.html#Quote-and-Quote-like-Operators">many other quote-like operators</a>.</p> - <p><a href="http://perldoc.perl.org/perlop.html#Quote-and-Quote-like-Operators">å¤ãã®ä»ã®ã¯ã©ã¼ãã©ã¤ã¯ãªãªãã¬ã¼ã¿</a>ãããã¾ãã</p> + <p><a href="http://perldoc.jp/docs/perl/perlop.pod#Quote32and32Quote-like32Operators">å¤ãã®ä»ã®ã¯ã©ã¼ãã©ã¤ã¯ãªãªãã¬ã¼ã¿</a>ãããã¾ãã</p> </li> <li> <p class="original">In <code>=~ m//</code> and <code>=~ s///</code> operations, you can use braces instead of slashes as the regex delimiters. This is quite useful if your regex contains a lot of slashes, which would otherwise need escaping with backslashes. For example, <code>=~ m{///}</code> matches three literal forward slashes, and <code>=~ s{^https?://}{}</code> removes the protocol part of a URL.</p> @@ -2001,7 +2001,7 @@ </li> <li> <p class="original">If you see a block of unformatted code wrapped in a delimiter with double chevrons, like <code><a href="http://perldoc.perl.org/perlop.html#Quote-and-Quote-like-Operators"><<EOF</a></code>, the magic word to Google for is "here-doc".</p> - <p>like <code><a href="http://perldoc.perl.org/perlop.html#Quote-and-Quote-like-Operators"><<EOF</a></code>ã®ããã«ã2ã¤ã®å±±æ¬å¼§ã§åºåããã¦ã©ãããããæ´çããã¦ããªãã³ã¼ãã®ãããã¯ãè¦ãããGoogleæ¤ç´¢ã®ããã®ãã¸ãã¯ã¯ã¼ãã¯"ãã¢ããã¥ã¡ã³ã(here-doc)"ã§ãã</p> + <p>like <code><a href="http://perldoc.jp/docs/perl/perlop.pod#Quote32and32Quote-like32Operators"><<EOF</a></code>ã®ããã«ã2ã¤ã®å±±æ¬å¼§ã§åºåããã¦ã©ãããããæ´çããã¦ããªãã³ã¼ãã®ãããã¯ãè¦ãããGoogleæ¤ç´¢ã®ããã®ãã¸ãã¯ã¯ã¼ãã¯"ãã¢ããã¥ã¡ã³ã(here-doc)"ã§ãã</p> </li> <li> <p class="original">Warning! Many built-in functions can be called with no arguments, <strong>causing them to operate on <code>$_</code> instead</strong>. Hopefully this will help you understand formations like:</p>