I am trying to print the contents of the array from within the hash. I
see that I can do it by

 print "$name: $items[0][0] $items[0][1] $items[0][2] $items[0][3]  \n "

Is there a better way to accomplish this, especially if I don't know the
number of items in the array.

Here is the code:
        while (( my $name, my @items) = each(%all)) {
                        my $len = @items;
                        print "this is len=>$len\n";
#               print "$name: $items[0][0] $items[0][1] $items[0][2]
$items[0][3] [EMAIL PROTECTED] \n ";
                print Dumper(@items);
        }



Entire code:

#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;

        my @gilligan = qw(red_shirt hat  lucky_socks water_bottle);
        my @skipper = qw ( blue_shirt  hat preserver  sunscreen);
        my @professor = qw(sunscreen water_bottle slide_rule batteries
radio);

        my %all = (
                    "Gilligan" => [EMAIL PROTECTED],
                    "Skipper" =>  [EMAIL PROTECTED],
                    "Professor" => [EMAIL PROTECTED],
                  );

warn Data::Dumper::Dumper (\%all);
        check_items_for_all(\%all);

        sub check_items_for_all{
                my $all = shift;
                for my $person(sort keys %$all) {
                        check_items_required($person, $all->{$person});
                } #end for
        } #end check_items_for_all

        sub check_items_required {
                my $who = shift;
                my $items = shift;
                my @missing = ();
                my @required = qw(preserver sunscreen water_bottle
jacket);

                for my $item (@required) {
                        unless (grep $item eq $_, @$items) { #if
statement is false
                        print "$who is missing $item\n";
                        push @missing, $item;
                        } #end unless
                 } #end for
                if (@missing) {
                        push @$items, @missing;
                        print "$who now has @$items\n\n";
                } #end if
        } #end sub
        while (( my $name, my @items) = each(%all)) {
                        my $len = @items;
                        print "this is len=>$len\n";
#               print "$name: $items[0][0] $items[0][1] $items[0][2]
$items[0][3]  \n ";
                print Dumper(@items); # I want to print the contents of
dumper
        }
        foreach my $line (@gilligan) {
        print "Gilligan: $line\n";
        }

Reply via email to