First, thanks in advance to anyone who takes the time to help me.

Second, I am self-taught, new to perl, so please try to make answers easy to read aka: simple.

Question: I am needing a script that will allow someone to enter multiple diagnosis codes (100+) in a text file or CSV file or array and then those diagnosis codes will match up with another list in a text file or CSV file or multiple arrays and if they match they will be renamed with their technical diagnosis name. This is what I have so far…

my $Search = qw(6280); if ( @found = grep { $_ eq $Search } @array) { my $found = join ",", @found; print "Primary Diagnosis: Meningitis, $found\n"; } if ( @found = grep { $_ eq $Search } @Encephalitis_77 ) { my $found = join ",", @found; print "Primary Diagnosis: Encephalitis, $found\n"; } else { print "Sorry, \"$Search\" not found in diagnosis list\n"};

But this only allows me to search one diagnosis code at a time which won’t work and it’s so much coding because I will have to do a grep function for each diagnosis and there are 1,000+. There must be a simpilar way!! Also, I am then needing the script to determine if one code was found more than any other code and label that as the patient’s primary diagnosis.

I have tried listing them in arrays, in hashes with arrays, in text files, in CSV files and unfortunately I may get it to find a couple codes, but I can’t figure out how to rename multiple codes and then also find the code that was matched the most. Hope this question is clear. Thank you for your help.


In reply to 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.