At 11:05 PM -0500 3/27/12, Chris Stinemetz wrote:
Hello list,

I am getting the results I want with this iteration through the hash,
but I am stump on clearing the following warnings:

fyi line 12168 is the last line of the input file.

Use of uninitialized value in concatenation (.) or string at
./TESTdeltaT1.pl line 54, <$SUM> line 12168.
Use of uninitialized value in concatenation (.) or string at
./TESTdeltaT1.pl line 54, <$SUM> line 12168.
Use of uninitialized value in concatenation (.) or string at
./TESTdeltaT1.pl line 54, <$SUM> line 12168.
Use of uninitialized value in concatenation (.) or string at
./TESTdeltaT1.pl line 54, <$SUM> line 12168.
Use of uninitialized value in concatenation (.) or string at
./TESTdeltaT1.pl line 54, <$SUM> line 12168.
Use of uninitialized value in concatenation (.) or string at
./TESTdeltaT1.pl line 54, <$SUM> line 12168.
Use of uninitialized value in concatenation (.) or string at
./TESTdeltaT1.pl line 54, <$SUM> line 12168.

Any ideas on how to resove it?

code snippet:
    51  foreach my $cell ( @wanted ) {
    52    print $DELTA "$cell:";
    53    foreach my $hr ( @hours ) {
    54      if ( defined keys %{ $href->{$hr}}){


This line makes no sense. What is $href->{$hr} a reference to? keys returns a list. You should not be testing a list for definedness. You normally want to know if there any elements in the hash. An empty hash evaluates to zero (false) in scalar context, such as in an if statement. So 'if( %{$href->{$hr}} ) will tell you if there are any elements in the hash. However, you can just iterate over the elements, which does nothing if there are none.


    55        print $DELTA "\t$href->{$cell}{$hr}";


Above you tested $href->{$hr}, but now you are using $href->{$cell}{$hr}. What is the relation supposed to be? It looks like $href->{$cell} or $href->{$cell}{$hr} does not exist.

    56      }
    57      else {
    58        print $DELTA "\t";
    59      }
    60    }
    61    print $DELTA "\n";
    62  }

It is always better to post a complete, short, working program rather than a snippet.


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to