in reply to Sparse Array
Since we know that the elements are 0, 1, and 2, the output should be 3 elements.#!/usr/bin/perl use strict; use warnings; my %sparse; @sparse{1,1,1,0,0,1,1,0,2,1,1,1,1,1} = (); print "There are ", scalar keys %sparse, " elements in this array\n";
|
|---|