Chris wrote:
I am working a script that is a solution to a problem in Intermediate
Perl. Here is the script:
#!/usr/bin/perl -w
use strict;
sub check_items_for_all {
my $all_ref = @_;
my $all_ref = shift @_;
my @who = keys %$all_ref;
my @required = qw(preserver sunscreen water_bottle jacket);
my @missing = ( );
for my $crew (@who){
for my $item(@required){
unless (grep $item eq $_, %$all_ref{$crew}) {
unless( grep $item eq $_, @{ $all_ref->{$crew} } ){
print "$crew is missing $item.\n";
#push @missing, $item;
}
}
}
#if (@missing) {
# print "Adding @missing to @$items for $who.\n";
# push @$items, @missing;
#}
}
my @gilligan = qw(red_shirt hat lucky_socks water_bottle);
my @skipper = qw(blue_shirt hat jacket preserver sunscreen);
my @professor = qw(sunscreen water_bottle slide_rule batteries radio);
my %all = (
Gilligan => [EMAIL PROTECTED],
Skipper => [EMAIL PROTECTED],
Professor => [EMAIL PROTECTED],
);
check_items_for_all(\%all);
When I run the script, I get the following error message:
syntax error at required_items.pl line 13, near "$all_ref{"
syntax error at required_items.pl line 18, near "}"
I'm not sure what is causing this. Eventually, I want the script to
access each crew member's belongings, figure out which of the items in
the @required array are missing, and place those items in the member's
array. Any hints?
--
Just my 0.00000002 million dollars worth,
Shawn
"For the things we have to learn before we can do them, we learn by doing them."
Aristotle
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/