Perlã®å ´åãè¤éãªãã¼ã¿æ§é ã¯ãé
åã¨ããã·ã¥ã®çµã¿åããã§ãã
é常ãé
åãããã·ã¥ãå¦çããæã¯ãã«ã¼ãã«ãªãã¾ããã
ãã®æã«ãã«ã¼ãã®æ大å¤ãæå®ããªãã¨ãªãã¾ããã
ã«ã¼ãã®æ大å¤ã¯ãæ®éãé
åãããã·ã¥ã®è¦ç´ æ°-1ã«ãªãã¾ãã
å®ã¯ãè¤éãªãã¼ã¿æ§é ã®æãã«ã¼ãã®æ大å¤ãæ±ããã®ã«æ©ãæãããã®ã§ãã
ããã§ã以ä¸ã«ã¢ã³ãã§ã³ãç¨æãã¦ã¿ã¾ããã
åèã«ãªãã°ã幸ãã§ãã
â åºæ¬çãªé åã¨ããã·ã¥ã®è¦ç´ æ°ã®æ±ãæ¹ï¼æ大ã¤ã³ããã¯ã¹ãããï¼
- é åã®è¦ç´ æ°ã®æ±ãæ¹ã¯ãé åå¤æ°ãã¹ã«ã©ã¼ã³ã³ããã¹ãã§è©ä¾¡ãã¾ãã
- é åã®æ大ã¤ã³ããã¯ã¹ã®æ±ãæ¹ã¯ãé åå¤æ°ã®ãã¡ãã¼æåã@ããã$#ãã«å¤ãã¾ãã
- ããã·ã¥ã®ç´ æ°ã®æ±ãæ¹ã¯ãkeysé¢æ°ããã¾ãã¯valuesé¢æ°ã®ãªã¿ã¼ã³å¤ãã¹ã«ã©ã¼ã³ã³ããã¹ãã§è©ä¾¡ãã¾ãã
â ã¢ã³ãã§ã³
use strict; use warnings; print "â é å -----------------------------------------\n"; my @aa = (1, 2, 3); print $#aa, "\n"; # é åæ大ã¤ã³ããã¯ã¹ print scalar(@aa), "\n"; # é åè¦ç´ æ° print $aa[0], "\n"; # è¦ç´ ã¢ã¯ã»ã¹ä¾ print "â ããã·ã¥ -------------------------------------\n"; my %hh = (a => 1, b => 2, c => 3); print scalar(keys(%hh)), "\n"; # ããã·ã¥è¦ç´ æ° print scalar(values(%hh)), "\n"; # ããã·ã¥è¦ç´ æ° print $hh{a}, "\n"; # è¦ç´ ã¢ã¯ã»ã¹ä¾ print "â é åã®é å -----------------------------------\n"; my @aa_aa = ([1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]); print $#aa_aa, "\n"; # ï¼æ¬¡å é åæ大ã¤ã³ããã¯ã¹ print scalar(@aa_aa), "\n"; # ï¼æ¬¡å é åè¦ç´ æ° print $#{$aa_aa[0]}, "\n"; # ï¼æ¬¡å é åæ大ã¤ã³ããã¯ã¹ print scalar(@{$aa_aa[0]}), "\n"; # ï¼æ¬¡å é åè¦ç´ æ° print $aa_aa[0][0], "\n"; # è¦ç´ ã¢ã¯ã»ã¹ä¾ print "â é åã®ããã·ã¥ -------------------------------\n"; my %hh_aa = (a => [1, 2, 3], b => [4, 5, 6], c => [7, 8, 9]); print scalar(keys(%hh_aa)), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(values(%hh_aa)), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print $#{$hh_aa{a}}, "\n"; # ï¼æ¬¡å é åæ大ã¤ã³ããã¯ã¹ print scalar(@{$hh_aa{a}}), "\n"; # ï¼æ¬¡å é åè¦ç´ æ° print $hh_aa{a}[0], "\n"; # è¦ç´ ã¢ã¯ã»ã¹ä¾ print "â ããã·ã¥ã®é å -------------------------------\n"; my @aa_hh = ({a => 1, b => 2}, {c => 3, d => 4}); print $#aa_hh, "\n"; # ï¼æ¬¡å é åæ大ã¤ã³ããã¯ã¹ print scalar(@aa_hh), "\n"; # ï¼æ¬¡å é åè¦ç´ æ° print scalar(keys(%{$aa_hh[0]})), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(values(%{$aa_hh[0]})), "\n";# ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print $aa_hh[0]{a}, "\n"; # è¦ç´ ã¢ã¯ã»ã¹ä¾ print "â ããã·ã¥ã®ããã·ã¥ ----------------------------\n"; my %hh_hh = (x => {a => 1, b => 2}, y => {c => 3, d => 4}); print scalar(keys(%hh_hh)), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(values(%hh_hh)), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(keys(%{$hh_hh{x}})), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(values(%{$hh_hh{x}})), "\n";# ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print $hh_hh{x}{a}, "\n"; # è¦ç´ ã¢ã¯ã»ã¹ä¾ print "â é åã®é åã®é å--------------------------------\n"; my @aa_aa_aa = ([[1, 1], [2, 2]], [[3, 3], [4, 4]], [[5, 5], [6, 6]]); print $#aa_aa_aa, "\n"; # ï¼æ¬¡å é åæ大ã¤ã³ããã¯ã¹ print scalar(@aa_aa_aa), "\n"; # ï¼æ¬¡å é åè¦ç´ æ° print $#{$aa_aa_aa[0]}, "\n"; # ï¼æ¬¡å é åæ大ã¤ã³ããã¯ã¹ print scalar(@{$aa_aa_aa[0]}), "\n"; # ï¼æ¬¡å é åè¦ç´ æ° print $#{$aa_aa_aa[0][0]}, "\n"; # ï¼æ¬¡å é åæ大ã¤ã³ããã¯ã¹ print scalar(@{$aa_aa_aa[0][0]}), "\n"; # ï¼æ¬¡å é åè¦ç´ æ° print $aa_aa_aa[0][0][0], "\n"; # è¦ç´ ã¢ã¯ã»ã¹ä¾ print "â é åã®é åã®ããã·ã¥----------------------------\n"; my %hh_aa_aa = (a => [[1, 2], [3, 4]], b => [[5, 6], [7, 8]]); print scalar(keys(%hh_aa_aa)), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(values(%hh_aa_aa)), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print $#{$hh_aa_aa{a}}, "\n"; # ï¼æ¬¡å é åæ大ã¤ã³ããã¯ã¹ print scalar(@{$hh_aa_aa{a}}), "\n"; # ï¼æ¬¡å é åè¦ç´ æ° print $#{$hh_aa_aa{a}[0]}, "\n"; # ï¼æ¬¡å é åæ大ã¤ã³ããã¯ã¹ print scalar(@{$hh_aa_aa{a}[0]}), "\n"; # ï¼æ¬¡å é åè¦ç´ æ° print $hh_aa_aa{a}[0][0], "\n"; # è¦ç´ ã¢ã¯ã»ã¹ä¾ print "â é åã®ããã·ã¥ã®é å--------------------------\n"; my @aa_hh_aa = ({a => [1, 1], b => [2, 2]}, {c => [3, 3], d => [4, 4]}); print $#aa_hh_aa, "\n"; # ï¼æ¬¡å é åæ大ã¤ã³ããã¯ã¹ print scalar(@aa_hh_aa), "\n"; # ï¼æ¬¡å é åè¦ç´ æ° print scalar(keys(%{$aa_hh_aa[0]})), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(values(%{$aa_hh_aa[0]})), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print $#{$aa_hh_aa[0]{a}}, "\n"; # ï¼æ¬¡å é åæ大ã¤ã³ããã¯ã¹ print scalar(@{$aa_hh_aa[0]{a}}), "\n"; # ï¼æ¬¡å é åè¦ç´ æ° print $aa_hh_aa[0]{a}[0], "\n"; # è¦ç´ ã¢ã¯ã»ã¹ä¾ print "â é åã®ããã·ã¥ã®ããã·ã¥--------------------------\n"; my %hh_hh_aa = (x => {a => [1, 1], b => [2, 2]}, y => {c => [3, 3], d => [4, 4]}); print scalar(keys(%hh_hh_aa)), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(values(%hh_hh_aa)), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(keys(%{$hh_hh_aa{x}})), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(values(%{$hh_hh_aa{x}})), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print $#{$hh_hh_aa{x}{a}}, "\n"; # ï¼æ¬¡å é åæ大ã¤ã³ããã¯ã¹ print scalar(@{$hh_hh_aa{x}{a}}), "\n"; # ï¼æ¬¡å é åè¦ç´ æ° print $hh_hh_aa{x}{a}[0], "\n"; # è¦ç´ ã¢ã¯ã»ã¹ä¾ print "â ããã·ã¥ã®é åã®é å--------------------------\n"; my @aa_aa_hh = ([{a => 1, b => 2}, {c => 3, d => 4}], [{e => 1, f => 2}, {g => 3, h => 4}]); print $#aa_aa_hh, "\n"; # ï¼æ¬¡å é åæ大ã¤ã³ããã¯ã¹ print scalar(@aa_aa_hh), "\n"; # ï¼æ¬¡å é åè¦ç´ æ° print $#{$aa_aa_hh[0]}, "\n"; # ï¼æ¬¡å é åæ大ã¤ã³ããã¯ã¹ print scalar(@{$aa_aa_hh[0]}), "\n"; # ï¼æ¬¡å é åè¦ç´ æ° print scalar(keys(%{$aa_aa_hh[0][0]})), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(values(%{$aa_aa_hh[0][0]})), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print $aa_aa_hh[0][0]{a}, "\n"; # è¦ç´ ã¢ã¯ã»ã¹ä¾ print "â ããã·ã¥ã®ããã·ã¥ã®é å--------------------------\n"; my @aa_hh_hh = ({x => {a => 1, b => 2}, y => {c => 3, d => 4}}, {z => {e => 1, f => 2}}); print $#aa_hh_hh, "\n"; # ï¼æ¬¡å é åæ大ã¤ã³ããã¯ã¹ print scalar(@aa_hh_hh), "\n"; # ï¼æ¬¡å é åè¦ç´ æ° print scalar(keys(%{$aa_hh_hh[0]})), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(values(%{$aa_hh_hh[0]})), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(keys(%{$aa_hh_hh[0]{x}})), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(values(%{$aa_hh_hh[0]{x}})), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print $aa_hh_hh[0]{x}{a}, "\n"; # è¦ç´ ã¢ã¯ã»ã¹ä¾ print "â ããã·ã¥ã®é åã®ããã·ã¥--------------------------\n"; my %hh_aa_hh = (z1 => [{a1 => 1, b1 => 2}, {x1 => 1, y1 => 2}], z2 => [{a2 => 1, b2 => 2}, {x2 => 1, y2 => 2}]); print scalar(keys(%hh_aa_hh)), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(values(%hh_aa_hh)), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print $#{$hh_aa_hh{z1}}, "\n"; # ï¼æ¬¡å é åæ大ã¤ã³ããã¯ã¹ print scalar(@{$hh_aa_hh{z1}}), "\n"; # ï¼æ¬¡å é åè¦ç´ æ° print scalar(keys(%{$hh_aa_hh{z1}[0]})), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(values(%{$hh_aa_hh{z1}[0]})), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print $hh_aa_hh{z1}[0]{a1}, "\n"; # è¦ç´ ã¢ã¯ã»ã¹ä¾ print "â ããã·ã¥ã®ããã·ã¥ã®ããã·ã¥----------------------\n"; my %hh_hh_hh = (z1 => {x1 => {a1 => 1, b1 => 2}, y1 => {c1 => 3, d1 => 4}}, z2 => {x2 => {a2 => 1, b2 => 2}, y2 => {c2 => 3, d2 => 4}}); print scalar(keys(%hh_hh_hh)), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(values(%hh_hh_hh)), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(keys(%{$hh_hh_hh{z1}})), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(values(%{$hh_hh_hh{z1}})), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(keys(%{$hh_hh_hh{z1}{x1}})), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print scalar(values(%{$hh_hh_hh{z1}{x1}})), "\n"; # ï¼æ¬¡å ããã·ã¥ã®è¦ç´ æ° print $hh_hh_hh{z1}{x1}{a1}, "\n"; # è¦ç´ ã¢ã¯ã»ã¹ä¾