in reply to Loading file into memory
If you are going to be doing it often, you may want to use dbmopen and make a db file, so you can skip the regexes on subsequent runs. You can also use Storable for this:
#!/usr/bin/perl use Storable; %hash = (1=>"one", 2=>"two", 3=>"three"); foreach $key (keys %hash) {print "$key => $hash{$key}\n"} print "###############################################\n"; store(\%hash, 'persistent-data.db'); # later on... #$href = retrieve('persistent-data.db'); # by ref %hashback = %{retrieve('persistent-data.db') }; # direct to hash foreach $key (keys %hashback){print "$key => $hashback{$key}\n"}
|
|---|