Welcome SayWhat?!,
Rather than debug your script for you, I hope I can make some suggestions for you to learn to better debug your scripts. Note: these are suggestions and after some years of doing your own debugging your suggestions could be very different than mine.
If your Perl supports it, use the 3 parameter version of open:
I like how you name your files, and you can do the same with Perl variables, i.e.open (my $FALSEF, "<", "FalseFriendsList.txt");
This will help your eyes see exactly what you wanted to emphasize when you look at the code sometime in the future. Also, I define a $Debug variable that I set to the level of debuggingmy %ExistingFalseFriend; # or my %existing_false_friend; # or my %Existing_False_Friend;
my $Debug = 3; # 0 - production, 1 - minor debugging, 2 .. 9 for + different levels
This leads to what is needed most in your script -- self-help debugging information. For example why not use a 'foreach' on the hash(or array) to see exactly what you just created.
Now in your debug log file, you may see that you didn't initialize the hash the way you wanted. Again, my suggestion of 'foreach' could have been replaced by a print statement inside the 'while' loop.#while the FF input exists while (my $line = <FALSEF> ) { # chomp off the new line chomp $line; # chomp could be part of while statement # increment $line $falsef{$line}++; } ### Now during debugging print to open log file if ( $Debug ) # this could be 'if ( 1==1 )' for testing, your + call { foreach my $key ( sort keys $falsef ) { print $LOG "$key\t$falsef{$key} } }
In general, I like your style and I'm sure it will get better and better.
Good Luck...Your on your way!
"Well done is better than well said." - Benjamin Franklin
In reply to Re: Comparing / Searching through Hashes
by flexvault
in thread Comparing / Searching through Hashes
by SayWhat?!
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |