in reply to looping through hash of hashes

Hello tangent.gardner, and welcome to the Monastery!

choroba++ has identified the logic error in your script. I just want to point out a few aspects of your code which could be improved.

  1. Perl is not C, and Perl’s function prototypes work quite differently. See perlsub#Prototypes. As a rule, it’s best to dispense with them altogether, unless you (a) have a particular use case which requires prototypes and (b) know how to use them correctly. See Far More than Everything You've Ever Wanted to Know about Prototypes in Perl -- by Tom Christiansen.

  2. This snippet of code:

    while (!eof(IN) ) { $_ = <IN>; $DEBUG = 1 if ($_ =~ m/^DEBUG/)

    can be written more idiomatically like this:

    while (<IN>) { $DEBUG = 1 if /^DEBUG/;
  3. The test if ($_ > 0) { which immediately follows the previous snippet throws warnings whenever $_ is not a number. You should add an additional test; for example:

    use Scalar::Util qw( looks_like_number ); ... if (looks_like_number($_) && ($_ > 0)) {
  4. In a conditional test, the type of the operands should match the type of the operator. The numeric comparison operators are == != < <= > >= <=>, and their string counterparts are eq ne lt le gt ge cmp (see perlop#Equality Operators). So, e.g., this line:

    if ($timings{$item}{STATUS} != '2') {

    would be better written either as:

    if ($timings{$item}{STATUS} ne '2') {

    (if the hash value is stored as a string), or as:

    if ($timings{$item}{STATUS} != 2) {

    (if the hash value is stored as a number). Yes, Perl will generally perform a silent string-to-number or number-to-string conversion where required, but it’s better practice to make your code self-documenting by using operands and operators of matching types.

  5. die should be used only for exceptions, not for normal program termination. The final lines of your main code would be better written as follows:

    for (;;) { ... if ($COMPLETE) { show_status(); print "finished\n"; last; } } close $log or die "Cannot close file '$log_file': $!";

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,