#!/usr/bin/perl use Tie::Persistent; my %a = (); tie %a , 'Tie::Persistent', "bigdatafile" , 'rw'; for my $i (1...5000) { $a{"ENTRY$i"}{"has"}{"a lot"}{"of data"}; } untie %a; #### #!/usr/bin/perl use strict; use Tie::Persistent; # use this time to look up the process # and see how much memory it consumes print "My Process ID is $$\nIn 10 seconds I will tie a big data file:\n"; for my $i (1..10) { print "$i\n"; sleep 1; } &loadData("bigdatafile"); # now look at memory usage again sleep 100; exit 0; sub loadData { my $file = shift; my %localhash = (); tie %localhash , 'Tie::Persistent', $file , 'rw'; print "File tied\n"; untie %localhash; print "File untied\n"; undef %localhash; }