As people have said is because your keys don't exists.
I've neatened up your code a bit, to make it more readable.
Some pointers:
- use English: This lets you use $INPUT_RECORD_SEPARATOR instead of $\ or $/ I can't even remember which one, I only knew from your input file
- use Data::Dumper: This lets you dump variables to see what's inside them
- use lowercase keys (lc) this ensures case isn't an issue


The output I get is:
john 10 50
mathew 27 40


Code:
#!/usr/bin/perl use warnings; use English q/-no_match_vars/; use strict; use Carp qw/croak carp/; use Data::Dumper; my $file_one_ref; my $file_one_fn = shift or croak "No input file specifed for file one" +; my $file_two_fn = shift or croak "No input file specifed for file two" +; open my $file_one_fh, '<', $file_one_fn or croak "Could not open filename [$file_one_fn] : ", $OS_ERROR; while (<$file_one_fh>) { $file_one_ref->{ lc $1 } = $2 if / \A (\w+) \s+ (\w+) /xms; } # You can do the above input like this but it's not as efficient: # map { $file_one_ref->{ lc $1 } = $2 if / (\w+) \s+ (\w+)/xms; } <$in +put_fh>; # Have a look at the keys read in: print Dumper($file_one_ref), "\n\n"; open my $file_two_fh, '<', $file_two_fn or croak "Could not open filename [$file_two_fn] : ", $OS_ERROR; $INPUT_RECORD_SEPARATOR = '>'; while ( my $line = <$file_two_fh> ) { # I reserve s{}{}xms; for multi line expressions next if ( $line !~ s/ \A (\S+) \s+ (?= \d ) //xms and !exists $fil +e_one_ref->{ lc $1 } ); # why not just use a match? is $name going to contain numbers my $name = lc $1; my $numbers = [ grep { $_ } split /\D+/, $line ]; my $one_number = $numbers->[ $file_one_ref->{$name} - 1 ] || next; if ( $one_number >= 20 ) { print join " ", $name, $file_one_ref->{$name}, $one_number, "\ +n"; } } close $file_one_fh or croak "Could not open filename [$file_one_fn] : ", $OS_ERROR; close $file_two_fh or croak "Could not open filename [$file_two_fn] : ", $OS_ERROR; __END__
Update: See below.

In reply to Re: Help to identify Error in my program by binf-jw
in thread Help to identify Error in my program by ashnator

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.