http://gihyo.jp/dev/serial/01/perl-hackers-hub/002001
ブレースを使ったデリファレンス
変数$arefに入っているリファレンスを配列としてデリファレンスするには,「@{$aref}」と書きます。
How to reference a split expression in Perl?
http://stackoverflow.com/questions/8444661/how-to-reference-a-split-expression-in-perl
(リスト:test_ref.pl)
#!/usr/bin/env perl while(<>){ chomp(); push(@records,[split(/\s+/)]); } @sorted = sort { @$a[1] <=> @$b[1] || @$b[0] <=> @$a[0] } @records; foreach $r (@sorted){ print @$r,"\n"; }
$ cat sample.txt 4 3 2 1 3 3 2 1 2 2 4 2 1 2 3 4 $ ./test_ref.pl sample.txt 2242 1234 4321 3321