Memoize |
BasicWerk
EC Support
Technique
Facebook
|
20141120121412_Perl_reference_to_array_and_hash |
Perl_reference_to_array_and_hash
リファレンスから値を取り出すにはいろいろな書き方がある。 #! /usr/bin/perl use warnings; use strict; my @array = (1, 2, 3); my $array_ref = \@array; # 以下全て出力は 2 print ${$array_ref}[1], "\n"; print $$array_ref[1], "\n"; print $array_ref->[1], "\n"; my %hash = ( 'a' => 'aaa', 'b' => 'bbb', 'c' => 'ccc', ); my $hash_ref = \%hash; # 以下全て出力は bbb print ${$hash_ref}{'b'}, "\n"; print $$hash_ref{'b'}, "\n"; print $hash_ref->{'b'}, "\n";
|
© Shin Nakamura/BasicWerk 2014 |