in reply to A Hashing Question
You should be using a DBM file for this. This is what DBM files were designed for. Take a look at perltie and dbmopen. I don't know what DBM libraries you have installed, but you'll definitely have at least SDBM_File, because it comes with Perl. If you have DB_File, use that.
If you're insistent on storing this in a file, try this code:
my $FILE = "joe.txt"; open FH, $FILE or die "Can't open $FILE: $!"; my %hash; while (<FH>) { chomp; my($key, $val) = split /=>/; $hash{$key} = $val; } close FH or die "Can't close $FILE: $!"; $myhash{$timestamp}=$newLine; open FH, ">" . $FILE or die "Can't open $FILE: $!"; print FH join("\n", map $_ . "=>" . $hash{$_}, keys %hash), "\n"; close FH or die "Can't close $FILE: $!";
|
|---|