use strict ; use warnings ; my %hash = () ; $hash{'dummy'} = undef ; printf STDERR "Single entry requires: %d Bytes\n", bytes($hash{dummy}) ; read_it() ; undef %hash ; show(0, \%hash) ; wait_for_it('Just "undef"ed the hash') ; read_it() ; sub read_it { open my $FH, "<", "hash.txt" ; wait_for_it('About to read') ; my $e = 0 ; my $c = show($e, \%hash) ; while (<$FH>) { $hash{$_} = undef ; $e++ ; $c = ($c - 1) || show($e, \%hash) ; } ; wait_for_it('Finished Reading') ; } ; sub show { my ($e, $rh) = @_ ; printf STDERR "%8d entries: %3.1fM Bytes\n", $e, mbytes($rh) ; return 50_000 ; } ; sub mbytes { my ($r) = @_ ; bytes($r)/(1024 * 1024) ; } ; use Devel::Size () ; sub bytes { my ($r) = @_ ; return Devel::Size::size($r) ; } ; sub wait_for_it { print STDERR "$_[0]..." ; my $ch = '' ; while ($ch !~ m/\./) { sysread STDIN, $ch, 1 ; } ; } ;