Dear Monks, I have 2 files:- 1) File 1 with format John 10 Andrew 16 Mathew 27 2) File 2 with format >John 40 34 40 40 40 40 40 40 40 50 40 40 40 40 40 40 40 20 40 40 40 30 40 4 +0 40 40 40 40 37 40 40 40 40 40 25 40 >Andrew 40 40 44 40 40 40 40 50 40 40 40 40 50 40 40 14 40 40 6 40 40 45 40 40 + 40 40 40 40 40 40 29 40 40 40 6 40 >Mathew 40 40 40 40 39 40 40 40 40 40 40 40 35 40 40 40 40 40 40 40 40 27 40 4 +0 40 40 40 40 33 40 40 40 40 4 40 40 I am parsing File 2 with File 1 values as hash. Now I pa +rse it like this. John in File 1 has a value of 10. So I parse File 2 + and check John Record at 10th position if the value is >= 20. If yes + then I print my results as: 3) Result File John 10 50 Now the problem is that I am getting the following error:- Use of uninitialized value in subtraction (-) at validator.pl line 24, + <FD> chunk 2. Use of uninitialized value in concatenation (.) or string at validator +.pl line 26, <FD> chunk 2. Here is My code:- #!/usr/bin/perl -w my %hashtable; my $fn = <>; ##### File 1 is the input. open(FH, "$fn") || die "Cannot open file"; while (<FH>) { chomp($_); $hashtable{$1} = $2 if $_ =~ /(\S+)\s+(\S+)/; } while (my ($key, $value) = each(%hashtable)) { #print $key. ", ". $value."\n"; } open(FD,"<File2.txt") || die("Can't open: $!"); $/ = '>'; while ( <FD> ) { chomp; next if ! s{ \A (\S+) \s+ (?= \d ) }{}xms; my $name = $1; my @numbers = split /\D+/; my $one_number = $numbers[$hashtable{$name} - 1]; ### Error warnin +g in this line if ( $one_number >= 20 ) { print "$name $hashtable{$name} $one_number\n"; ### Error warn +ing in this line } } Can you please help me to identify the Error !! Thanks

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