I'm doing some small programming in perl to improve the way significant figures are tracked for webwork... Some of my functions are not working and it seems to be the way the hash functions are being passed.
Here is a snip of my code. The makeSFhash creates a hash from a number with the fields: raw, sf and rounded. Since my other functions did not seem to be working, I did a passHash test function to see if my other functions were getting the hashes correctly. They weren't. It always tells me in the passHash function that they are not hash references. Any ideas?
sub passHash {
my (%m) = shift;
my (%n) = shift;
my $h;
$h = $m{"raw"};
return $h;
}
sub makeSFhash {
my ($n) = @_;
my ($sf,$rounded);
$sf = CountSigFigs($n);
$rounded = FormatSigFigs($n,$sf);
return("raw"=>$n,"sf"=>$sf,"rounded"=>$rounded);}
$percent = random(2.01,9.99,.02);
%percenthash = makeSFhash($percent);
$mass = random(401,999,2);
%masshash = makeSFhash($mass);
$test = passHash(%percenthash,%masshash);
Here is a snip of my code. The makeSFhash creates a hash from a number with the fields: raw, sf and rounded. Since my other functions did not seem to be working, I did a passHash test function to see if my other functions were getting the hashes correctly. They weren't. It always tells me in the passHash function that they are not hash references. Any ideas?
sub passHash {
my (%m) = shift;
my (%n) = shift;
my $h;
$h = $m{"raw"};
return $h;
}
sub makeSFhash {
my ($n) = @_;
my ($sf,$rounded);
$sf = CountSigFigs($n);
$rounded = FormatSigFigs($n,$sf);
return("raw"=>$n,"sf"=>$sf,"rounded"=>$rounded);}
$percent = random(2.01,9.99,.02);
%percenthash = makeSFhash($percent);
$mass = random(401,999,2);
%masshash = makeSFhash($mass);
$test = passHash(%percenthash,%masshash);