B
bjobrien62
This is confusing me...
I have a patient id and that patient id can have a list of patient names (each with different spelling, but the same person)
my %hash = ();
my $pid = "Patient ID";
my $pname = "Patient Name";
I check to see if there is an entry in the hash for patient ID.
If there is then I want the array of Patient Names for the Patient ID.
Then I want to see if this spelling is found in the Array.
If it is do nothing, if it isn't then I add the new spelling to the array then set that array as the value for the hash pid.
if (exists($hash{$pid})) {
$pnames = $hash{$pid};
@found = grep(/$pname/, @pnames);
$size = @found;
if ($size == 0) {
push(@$names, $pname);
$hash{$pid} = [ @foo ];
}
} else {
$hash{$pid} = [ $pname ];
}
Then I want to print out the list...
my $patid = "";
foreach my $patid (keys %hash) {
print "The spellings for $patid are\n";
foreach (@{$hash{$patid}}) {
print "\t$_\n";
}
}
I have a patient id and that patient id can have a list of patient names (each with different spelling, but the same person)
my %hash = ();
my $pid = "Patient ID";
my $pname = "Patient Name";
I check to see if there is an entry in the hash for patient ID.
If there is then I want the array of Patient Names for the Patient ID.
Then I want to see if this spelling is found in the Array.
If it is do nothing, if it isn't then I add the new spelling to the array then set that array as the value for the hash pid.
if (exists($hash{$pid})) {
$pnames = $hash{$pid};
@found = grep(/$pname/, @pnames);
$size = @found;
if ($size == 0) {
push(@$names, $pname);
$hash{$pid} = [ @foo ];
}
} else {
$hash{$pid} = [ $pname ];
}
Then I want to print out the list...
my $patid = "";
foreach my $patid (keys %hash) {
print "The spellings for $patid are\n";
foreach (@{$hash{$patid}}) {
print "\t$_\n";
}
}