in reply to Re: Memory Error Printing Multiple Hashes Simultaneously
in thread Memory Error Printing Multiple Hashes Simultaneously
Thanks BrowserUK, I thought I was going crazy. I wonder if the extra factor might be the tabs themselves, as I can still get an out-of-memory error by replacing the join with manual tabs:
use strict; my %hash1; my %hash2; my %hash3; my @data = (0 .. 5000); for (my $i = 0; $i < scalar(@data); $i++ ) { for (my $j = $i; $j < scalar(@data); $j++) { $hash1{ $data[$i] }{ $data[$j] } = 0; $hash2{ $data[$i] }{ $data[$j] } = 0; $hash3{ $data[$i] }{ $data[$j] } = 0; } } print "Finished building hashes\n"; while ( my( $key1, $val1 ) = each %hash1 ) { while ( my( $key2, $val2 ) = each %$val1 ) { die 'Autovivify' unless exists $hash1{ $key1 } and exists $hash1{ $key1 }{ $key2 }; print "$key1\t$key2\t$hash1{ $key1 }{ $key2 }\t$hash2{ $key1 } +{ $key2 }\t$hash3{ $key1 }{ $key2 }\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Memory Error Printing Multiple Hashes Simultaneously
by BrowserUk (Patriarch) on Jan 31, 2006 at 17:37 UTC |