in reply to Re^2: Search multiple variables
in thread Search multiple variables

Put another loop around the loop over the diagnoses:

my @Search = qw( 6280 3141 2718 1414 ); my %frequency; for my $Search (@Search) { for my $diag ( keys %diags ) { if( my @found = grep { $_ eq $Search } @{$diags{$diag}} ) { my $found = join ",", @found; print "Primary diagnosis: $diag, $found\n"; $frequency{$Search}++; } } }

and then do something based on the %frequency of found diagnoses.

Replies are listed 'Best First'.
Re^4: Search multiple variables
by Raya4505 (Novice) on Feb 25, 2014 at 15:14 UTC

    Did anyone every tell you that you are a genius? Because you definitely are. Thank you so much for helping me. thank you for everyone else who responded. I have used some of the other comments in other scripts of mine.

      Thanks for your praise but this is rather basic Perl. If you think it useful, hang on to it, learn and practise. You can be there in no time as well.