G'day Raya4505,

Welcome to the monastery.

Firstly, I'm unsure on a couple of things so I've assumed: @array and @Encephalitis_77 are two different sources that you want to search; and, @found contains related information beyond the "Primary Diagnosis". You'll probably need to make changes to the example code below; however, the basic technique should be valid.

If you organise your data into a hash with a structure like this:

code1 => { source1 => { primary => 'diagnosis', other => 'information', }, source2 ... }, code2 ...

You can write a short subroutine to quickly search for the information you want. The basic technique (with a couple of example searches) are shown in this script:

#!/usr/bin/env perl -l use strict; use warnings; my %data_for = ( 6280 => { array => { primary => 'Meningitis', other => 'Other relevant info ...', }, Encephalitis_77 => { primary => 'Encephalitis', other => 'Other relevant info ...', }, }, ); search_for_diagnosis_code($_) for (6280, 9999); sub search_for_diagnosis_code { my ($search) = @_; print "Searching for '$search' ..."; if (exists $data_for{$search}) { for my $source (keys %{$data_for{$search}}) { print "\tFound in '$source':"; print "\t\tPrimary Diagnosis: $data_for{$search}{$source}{ +primary}"; print "\t\tOther Information: $data_for{$search}{$source}{ +other}"; } } else { print "\tNo data found."; } }

Output:

Searching for '6280' ... Found in 'array': Primary Diagnosis: Meningitis Other Information: Other relevant info ... Found in 'Encephalitis_77': Primary Diagnosis: Encephalitis Other Information: Other relevant info ... Searching for '9999' ... No data found.

-- Ken


In reply to Re: Search multiple variables by kcott
in thread Search multiple variables by Raya4505

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.