in reply to Search multiple variables
If you have all diagnoses in arrays you could do the following:
use strict; use warnings; my %diags = ( "Meningitis" => \@array, "Encephalitis" => \@Encephalitis_77, # more of them here ); my $Search = qw( 6280 ); my $found_one = 0; for my $diag ( keys %diags ) { if( my @found = grep { $_ eq $Search } @{$diags{$diag}} ) { my $found = join ",", @found; print "Primary diagnosis: $diag, $found\n"; $found_one = 1; } } print "Sorry, \"$Search\" not found in diagnosis list\n" unless $found +_one;
Disclaimer: have not run this due to lack of sample data, so there might be errors in there. But the concept should be clear.
Update: changed @$diag to @{$diags{$diag}}.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Search multiple variables
by Raya4505 (Novice) on Feb 20, 2014 at 20:53 UTC | |
by hdb (Monsignor) on Feb 21, 2014 at 07:15 UTC | |
by Raya4505 (Novice) on Feb 25, 2014 at 15:14 UTC | |
by hdb (Monsignor) on Feb 25, 2014 at 15:24 UTC |