my %hash my $UL=1000; foreach $a ( 1..$UL ) { foreach $b ( 1..$UL ) { $hash{$a*$b}++; } }