Combo ActiveState Perl 5.6.1 635 and Apache 1.0.xx from www.perl.apache.org
<http://www.perl.apache.org> .
 
The following code goes round the foreach twice as often as I think it
should.  (I realise the code is probably not particularly stylish, but I'd
prefer to leave that alone for the moment.)
 
require 'xxxconstant.pl'; # not shown
require 'xxxlib.pl'; # not shown
 
use strict;
use warnings;
use CGI::Carp qw( fatalsToBrowser );
use Data::Dumper;

my $capval;
our %capdef;

&xxxlib::set_capdef;# Create the hash.

sub bynumber { $a <=> $b; }
 
select STDERR;
$| = 1;
print STDERR Dumper(%capdef); # <-- print 1

my $counter = 0;
foreach $capval ( sort bynumber %capdef ) {
  $counter++; # debug
  if (defined $capdef{$capval}) { # debug
    print STDERR $counter . " " . $capval . " " . Dumper($capdef{$capval}) .
"\n"; # <-- print 2
    my @elcdev = split(/;/, $capdef{$capval}{'ELIGELC'});
    my @tlcdev = split(/;/, $capdef{$capval}{'ELIGTLC'});
    # Useful stuff originally went here.
  } else { # debug
    print STDERR "Haha!" . $counter . "\n"; <-- print 3 debug
  } # debug
}
 
exit 0;
 
As examples, here are the last two items from the line 'print 1'.  I assume
VAR341 is the key and VAR342 the contents.  Thus there are 171 items in the
hash.
 
$VAR339 = '35';
$VAR340 = {
            'CAPDESC' => '35 TB',
            'ELIGTLC' => '1;2;3;102;104',
            'CAPVAL' => '35',
            'ELIGELC' => '1;2;3;102;104'
          };
$VAR341 = '36';
$VAR342 = {
            'CAPDESC' => '36 TB',
            'ELIGTLC' => '1;2;3;102;104',
            'CAPVAL' => '36',
            'ELIGELC' => '1;2;3;102;104'
          };
 
And the first two items from 'print 2' are:-
 
1 0 $VAR1 = {
          'CAPDESC' => '0 TB (New)',
          'ELIGTLC' => '0',
          'CAPVAL' => '0',
          'ELIGELC' => '1;2;3;102;104;500'
        };
2 1 $VAR1 = {
          'CAPDESC' => '1 TB',
          'ELIGTLC' => '1;2;3;102;104',
          'CAPVAL' => '1',
          'ELIGELC' => '1;2;3;102;104'
        };

'print 2' shows 171 items as expected.
 
And then --- I get Haha!172 thru Haha!342 from 'print 3'.
 
What is going on that I haven't understood?
 
Rgds, GStC.
 
 

 
 
 

Reply via email to