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
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |