in reply to Help to identify Error in my program
If you are going to present us with error messages that include line numbers, you should indicate in your code which lines those numbers represent. I'm guessing that the two messages you quoted -- which are actually warnings (not errors) -- refer to the two lines marked below:
This would suggest that those messages resulted from an iteration of your while <FD> loop in which the variable "$name" was set to a value that happened to be non-existent as a key in "%hashtable". If you change your test condition from this:my $one_number = $numbers[$hashtable{$name} - 1]; # line 24 if ( $one_number >= 20 ) { print "$name $hashtable{$name} $one_number\n"; # line 26 }
to something like this instead:next if ! s{ \A (\S+) \s+ (?= \d ) }{}xms;
then the warnings should go away (and you might end up with fewer lines of printed output).next unless ( s{ \A (\S+) \s+ (?= \d ) }{}xms and exists( $hashtab +le{$1} ));
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
| A reply falls below the community's threshold of quality. You may see it by logging in. |