#!/usr/bin/perl use strict; use warnings; # the program my %hash = ( 'one' => [1], 'two' => [2,2], 'three' => [3,3,3], ); print "$hash{one}[0]\n"; print "$hash{two}[0]\n"; print "$hash{three}[0]\n"; while (my ($key, $aref) = each %hash) { # dereference array_reference # (and the @$aref array is in scalar context) printf "key=%s size=%d\n", $key, @$aref; } #### 1 2 3 key=three size=3 key=one size=1 key=two size=2