Use of uninitialized value in exists at C:\test\632320.pl line 161.
Use of uninitialized value in null operation at C:\test\632320.pl line
+ 161.
Use of uninitialized value in hash element at C:\test\632320.pl line 1
+67.
Use of uninitialized value in hash element at C:\test\632320.pl line 1
+67.
Use of uninitialized value in hash element at C:\test\632320.pl line 1
+67.
Use of uninitialized value in hash element at C:\test\632320.pl line 1
+67.
Use of uninitialized value in exists at C:\test\632320.pl line 161.
...
It's not at all clear to me what a 'null operation' is, (I don't think I ever encountered that one before :), but the main problem appears to be that your code is still displaying signs of its no strict; heritage.
Specifically, within your compare sub, you have the loop iterator declared ahead of the first loop:
my $k;
foreach $k ( keys %{ $hrefA } ) {
which is rarely better than declaring it in line, but is sometimes necessary if you wish to retain its value beyond the end of the loop.
However, in the next loop, which is only entered if you found whatever you are looking for in the first, you have no loop iterator variable, but do not appear to use $_ anywhere within it?
And the first thing you do within that second loop is test if the value of $k exists as a key within $hrefA.
if ($result) {
foreach (keys(%{$hrefB})) { ## No loop variable
if ( exists $hrefA->{$k} ) { ## line 161
But, as the value of $k is being retained from the first loop where it is explicitly looping over the keys of $hrefA (as shown above), then that test would appear to be redundant.
Except, the undefined warning for line 161 relates to the fact that somehow you are reaching this line with $k undefined.
My best guess, without having tried to work my way through and understand everything you are doing, is that your second loop is meant to be iterating the keys of $hrefB and checking whether they exist in $hrefA, and that if you replaced those two snippets with;
## my $k;
foreach my $k ( keys %{ $hrefA } ) {
...
if ($result) {
foreach my $k (keys(%{$hrefB})) { ## No loop variable
if ( exists $hrefA->{$k} ) { ## line 161
That might eliminate a large number of the warnings, and might also get you closer to making your code do what you are expecting.
Until you eliminate all the warnings your code is producing, it is impossible (or at least, asking a lot) for us to see symptoms of the problem you describe and so attempt to help you solve that problem.
I don't insist on use strict; use warnings; although I always use them myself, but in this case, it is very obvious that your code is not doing what you think it is doing, and if you had them enabled, you would have realised it yourself.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|