
airo
stranger
Apr 5, 2001, 6:40 PM
Post #1 of 4
(1374 views)
|
text file to hash??
|
Can't Post
|
|
How do I…….? I’m trying to get the hash from the text file so I can get the values from each key --one at a time—and write them to a new file with HTML stuff to display the info. Each section within the new file(HTML) will be the same. So for example print NEW "<input type=text name=image value= $hash{key}[value] size=4>", "\n"; Here is the script I have to this point: The text file looks like this: db0001 # this is a keyvalue I use to keep from having duplicates. 0001: # this is the first key of the hash http://127.0.0.1/clients/test500/proofs/ 0001 1 1 1 1 10 15 20 45 90 0.5 0.8 1 1.2 3.5db0001 # this is a keyvalue I use to keep from having duplicates. db0002 # this is a keyvalue I use to keep from having duplicates. 0002: # this is the second key of the hash http://127.0.0.1/clients/test500/proofs/ 0002 2 2 2 2 20 30 40 90 180 1 1.6 2 2.4 7 db0002 # this is a keyvalue I use to keep from having duplicates. This is the script I use to write the hash to the text file: open(DB, ">>$db") || die "Can't open $db: $!"; print DB "$delkey", "\n"; #this is the key to check for dups. foreach my $key (keys %hash){ print DB "$key: \n"; foreach my $value (@{$hash{$key}}){ print DB "$value\n"; } } print DB "$delkey", "\n"; #this is the key to check for dups. close(DB);
|