Hello,
I have a function that is doing some calculations and then passes some properties into another subroutine like so:
sub get_result {
my $id = 1;
my %diet = ( result => 28,
verdict => 'EAT MORE FRUIT DUDE...'
);
my %iq = ( result => 193,
verdict => 'Professor Einstien'
);
print_result($id, %diet, %iq);
}
sub print_result {
my $id = shift;
my %d = @_;
my %i = @_;
print "IQ: $id\n";
print "DIET RESULT: $d{result}\n";
print "DIET VERDICT: $d{verdict}\n";
print "IQ RESULT: $i{result}\n";
print "IQ VERDICT: $i{verdict}\n";
}
My problem is that the results printed in (DIET RESULT, DIET VERDICT) and (IQ SCORE, IQ RESULT) are both the same. As if variable %d and %i are being populated with the same variables. Any ideas why this is?
If I try shifting all three variables like so:
my $id = shift;
my %d = shift;
my %i = shift;
I get the following error:
Odd number of elements in hash assignment