のLISTとarrayとhashとreference。@%()[]{}の違いがやっと分かった。

http://perldoc.perl.org/perlreftut.html
http://perldoc.perl.org/perlintro.html#Perl-variable-types

#!/usr/bin/perl -w
use strict;
use Data::Dumper;
use encoding('euc-jp');
binmode(STDERR, ':raw :encoding(euc-jp)');

my @array = ("a", "b", "c");
my %hash = ("a", "b", "c", "d");
print Dumper(\@array);
print Dumper(\%hash);

my $aref = ["a", "b", "c"];
my $href = {"a", "b", "c", "d"};
print Dumper($aref);
print Dumper($href);
$ perl hashhash.pl
$VAR1 = [
          'a',
          'b',
          'c'
        ];
$VAR1 = {
          'c' => 'd',
          'a' => 'b'
        };
$VAR1 = [
          'a',
          'b',
          'c'
        ];
$VAR1 = {
          'c' => 'd',
          'a' => 'b'
        };

自分の言葉で定義:

  • @hogeは配列の変数を作るって意思表示
  • %hogeはハッシュの変数を作るって意思表示
  • 右辺の()はリストを渡すときの方法
  • 右辺の[]は配列のリファレンスを返す。なので左辺は@hogeじゃなくてスカラーの$hogeになる。
  • 右辺の{}はハッシュのリファレンスを返す。なので左辺は%hogeじゃなくてスカラーの$hogeになる。

きちんとした定義は:
http://perldoc.perl.org/perldata.html