Hi,
I am really having problems trying to put a new item into a hash of an array and passing it by reference I am afraid my code is way off the mark can someone please help me with it?
Thanks,
margamo
This is my code:
#!usr/bin/perl
use strict;
my $groceryStore = {
"fruits" => {
items => [ qw(perl plum apple) ],
bin => {
ailse => "1",
section => "B"
}
};
$newFruit = 'orange';
newProduce(%items, $newFruit);
sub newProduce { # given produce type, and item name, add to items
my (%$rh_items, $fruit) = @_;
push (%$rh_items, $fruit);
}
I am really having problems trying to put a new item into a hash of an array and passing it by reference I am afraid my code is way off the mark can someone please help me with it?
Thanks,
margamo
This is my code:
#!usr/bin/perl
use strict;
my $groceryStore = {
"fruits" => {
items => [ qw(perl plum apple) ],
bin => {
ailse => "1",
section => "B"
}
};
$newFruit = 'orange';
newProduce(%items, $newFruit);
sub newProduce { # given produce type, and item name, add to items
my (%$rh_items, $fruit) = @_;
push (%$rh_items, $fruit);
}