Here's the flip side of yesterday's array question. Now that I know how to pass associative arrays out of a routine, I'm having trouble trying to use them in other routines. The best I can figure from reading is that I need to pass them by reference, but in practice, the terminal always fills up with "uninitialized value" messages when I try to use the array values inside subroutines. Could someone show me how to make this work?

Thanks in advance,

Ken

my %wombatStats = GetWombat();
my $description = DescribeCritter(\% wombatStats);
print $description;

sub DescribeCritter
{
my %input_rec = $_[0];
my $result = "";

$result .= $input_rec{'name'}
$result .= ' is a '.$input_rec{'kind_of_animal'}
$result .= ' whose favorite past time is eating '. $input_rec{'favorite_food'}
$result .= ' and '. $input_rec{'favorite_hobby'}
$result .= ' on the beach in '. $input_rec{'favorite_vacation_spot'}
return $result;
}


sub GetWombat
{
        my %result = ();
        $result{'kind_of_animal'} = "wombat";
        $result{'name'} = "Theodore";
        $result{'favorite_food'} = "nachos";
        $result{'favorite_hobby'} = "burping";
        $result{'favorite_vacation_spot'} = "Cancun";
        return %result;
}


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to