
kencl
User
Nov 13, 2003, 1:05 AM
Post #4 of 7
(936 views)
|
|
Re: [woffs] How to store in file complex hash?
[In reply to]
|
Can't Post
|
|
Choose a delimiter that is guaranteed not to be used in any key or in val1. I'll use TAB (\t) for this example: Storing the file: for (keys $hash) { print FILE "$_\t$hash{$_}[0]\t$hash{$_}[1]\n"; } Reading the file: while ($line = <FILE>) { chomp($line); my ($key, $val1, $val2) = split(/\t/, $line, 3); $hash{$key} = [$val1, $val2]; } >> If you can't control it, improve it, correlate it or disseminate it with PERL, it doesn't exist!
|