# # initialisation # @home = ( "couch", "chair", "table", "stove"); @temp = qw( foo bar); # quote words @ones = (1) x 80; # fills with 80 ones @arr = ((map { 19 + $_ * 0.1} (1 .. 5)), # @arr receives 10 elements, the (map { 22 + $_ * 0.2} (1 .. 5))); # first is 19.1, the last 23 # # manipulation # @whatever = @home; # copies the items $home[0] = "door"; # set the first element ($s1, $s2, $s3, $s4) = @home; @temp = (@foo, @bar, &SomeSub); # interpolation of sublists ($a, $b, @rest) = split; $home = @stuff; # $home gets 4 (length) $home = scalar( @stuff); # $home gets 4 (length) print $#home; # subscript of the last element @home = (); # clear list $#home = -1; # clear list scalar( @x) == $#x + 1; # always true print "$home[-1]\n"; # print last element # # Array references # $ra = \@ARGV; # reference to an array $ra = [1, 2, 3]; # reference to an anon array print " -- @$ra \n"; $$ra[0] = "January"; $ra->[0] = "January"; ${$ra}[0] = "January"; # a block returns a reference