Help for this page

Select Code to Download


  1. or download this
    my $sales = {
    monday => { jim => [ 2 ], mary => [ 1, 3, 7 ] },
    ...
    thursday => { jim => [ 4 ], mary => [ 5, 7, 2, 5, 2 ] },
    friday => { jim => [ 1, 1, 5 ], mary => [ 2 ] },
    };
    
  2. or download this
    my $commissions = $sales->{tuesday}{jim};
    my $num_sales   = @$commissions;
    ...
        $total += $_;
    }
    print "Jim made $num_sales sales on Tuesday and earned \$$total commis
    +sion\n";
    
  3. or download this
    my @fools = qw(jester clown motley);
    my $fools = \@fools;
    ...
    To access individual elements of the $fools array reference, you use t
    +he same syntax as you would
    to access the original array, but you use the dereferencing operator, 
    +->, between the array name and
    the square brackets.