Hi Monks

I'm trying to extract the key,value pair from a hash without first starting from a loop

my %VIS; my $key; my $value; my $mfunds="$ENV{'HOME'}/scripts/MFUNDS.txt"; my $evst="$ENV{'HOME'}/scripts/IN_EVST_NOT_IN_NFS.txt"; open MFUND, $mfunds or die "Can not open $mfunds\n"; while ( <MFUND> ) { chomp; my $aref = [split]; $VIS{$aref->[0]} = $aref->[1]; } open EVST, $evst or die "Can not open config file: $evst\n"; while ( <EVST> ) { chomp; my $aref = [split]; if (exists($VIS{$aref->[0]}) ) { print "$key, $value from %VIS\n"; } }

The code sample of course does not work, because i'm not quite sure how to accomplish the task

$mfunds contains 2 columns of data: a number and a description

$evst would contain 1 column of data: a number

so basically, if the number from $evst exists in $mfunds, then print the key, value (number,desc) from $mfunds

any help would be greatly appreciated

Tony


In reply to Get key and value pair from hash without loop by dirtdog

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.