Show
Ignore:
Timestamp:
09/01/08 00:20:26 (6 years ago)
Author:
tokuhirom
Message:

change text

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • websites/perl-users.jp/html/modern_introduction_perl/variables.html

    r17237 r18554  
    6666添え字は 1ではなく、0から開始します。</p> 
    6767<pre id="AddChar"><code><span class="synStatement">my</span> <span class="synIdentifier">@x</span> = (<span class="synConstant">&quot;one&quot;</span>, <span class="synConstant">&quot;two&quot;</span>, <span class="synConstant">&quot;three&quot;</span>); 
    68 <span class="synStatement">print</span> <span class="synIdentifier">$x</span>[ <span class="synConstant">0</span> ], <span class="synConstant">&quot;</span><span class="synSpecial">\n</span><span class="synConstant">&quot;</span>; <span class="synComment"># &quot;one&quot;</span> 
    69 <span class="synStatement">print</span> <span class="synIdentifier">$x</span>[ <span class="synConstant">1</span> ], <span class="synConstant">&quot;</span><span class="synSpecial">\n</span><span class="synConstant">&quot;</span>; <span class="synComment"># &quot;two&quot;</span> 
    70 <span class="synStatement">print</span> <span class="synIdentifier">$x</span>[ <span class="synConstant">2</span> ], <span class="synConstant">&quot;</span><span class="synSpecial">\n</span><span class="synConstant">&quot;</span>; <span class="synComment"># &quot;three&quot;</span> 
     68<span class="synStatement">print</span> <span class="synIdentifier">$x[</span> <span class="synConstant">0</span> <span class="synIdentifier">]</span>, <span class="synConstant">&quot;</span><span class="synSpecial">\n</span><span class="synConstant">&quot;</span>; <span class="synComment"># &quot;one&quot;</span> 
     69<span class="synStatement">print</span> <span class="synIdentifier">$x[</span> <span class="synConstant">1</span> <span class="synIdentifier">]</span>, <span class="synConstant">&quot;</span><span class="synSpecial">\n</span><span class="synConstant">&quot;</span>; <span class="synComment"># &quot;two&quot;</span> 
     70<span class="synStatement">print</span> <span class="synIdentifier">$x[</span> <span class="synConstant">2</span> <span class="synIdentifier">]</span>, <span class="synConstant">&quot;</span><span class="synSpecial">\n</span><span class="synConstant">&quot;</span>; <span class="synComment"># &quot;three&quot;</span> 
    7171</code></pre> 
    7272<p>配列のsigilが「<code>@</code>」から「<code>$</code>」に変化するのがわかりにくいかもしれませんが、これはどのような変数にアクセスしているのか考えるとわかりやすいかもしれません。</p> 
     
    7676</code></pre> 
    7777<p>配列の要素一個一個はスカラーですので、要素一個一個にアクセスする場合は「<code>$</code>」を使用します。</p> 
    78 <pre id="ScalarAccess"><code><span class="synStatement">print</span> <span class="synIdentifier">$list</span>[ <span class="synConstant">0</span> ]; 
     78<pre id="ScalarAccess"><code><span class="synStatement">print</span> <span class="synIdentifier">$list[</span> <span class="synConstant">0</span> <span class="synIdentifier">]</span>; 
    7979</code></pre> 
    8080<h3>ハッシュ</h3>