はじめてのPerlよんでる
コンテキストわからぬ……
サンプルコードを少し変更して色々やって見てる
$fred[0] = "yabba"; $fred[1] = "dabba"; $fred[2] = "doo"; print "\@fred[0]: " . @fred[0] . "\n"; print "\$fred[0]: " . $fred[0] . "\n";
結果
@fred[0]: yabba $fred[0]: yabba
もう一丁
print "\$fred: $fred\n"; $len = @fred; print "\$len = \@fred: $len\n";
結果
$fred: $len = @fred: 3
さらにもう一丁
print "embedded: @fred \n"; print "\@fred: " . @fred . "\n"; print "scalar \@fred: " . scalar @fred . "\n"; print "\@{ \@fred }: " . @{ @fred } . "\n";
結果
embedded: yabba dabba doo @fred: 3 scalar @fred: 3 @{ @fred }: 0
わけわからん……
ちなみに最初の宣言に "my" つけると
syntax error at fred.pl line 1, near "$fred[" syntax error at fred.pl line 2, near "$fred[" syntax error at fred.pl line 3, near "$fred["
怒られる……