#!/usr/bin/perl -w my %hashtable; my $fn = <>; ##### File 1 is the input. open(FH, "$fn") || die "Cannot open file";
First, do a favour to yourself and use strict as well. Then, if you don't chomp $fn, it will end with "\n" and be unlikely albeit not impossible to be the real filename you're after. Last, $fn is called "useless use of quoting." Well, it's not really "last" because I may point out that you'd better use lexical filehandles, the three args form of open, low precedence short circuiting logical operators, include both the name of the file and more importantly the cause of the error ($!) in the error message, etc. But I'll try to stick to pointing out only the major issues...
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
Indeed: what if $name is not a key of $hashtable? Appearently you have one or more names in the second file that are missing from the former. Try finding out which ones they are. A simple
say "<$name>" unless exists $hashtable{$name};
would do: the additional < and > marks are there to be sure about "hidden" characters like spaces. But if you want to be really fussy you may even try:
say map {my $_=$_; s/([^[:print:]])/sprintf '\\%03o', $1/ge; "<$_>"} $ +name unless exists $hashtable{$name};
In reply to Re: Help to identify Error in my program
by blazar
in thread Help to identify Error in my program
by ashnator
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |