C
christrier
Hi!
I have a problem with a file. It looks like this
;r;information;more_info;1;key1;value1;
;s;more;more;2;key1;value1;key2;value2;
;t;info;and;4;key1;value1;key2;value1;key1;value3;key2;value4
I have to extract the information in key and value of each line and
compare it to some information in another file.
I would like to read the file and store the key;value pairs into a hash
and then compare it later on with the other information I have.
As you can see (hopefully) in my example (i.e. line 3) I have some keys
that are used twice (or more often). My suggestion would be an hash of
arrays.
I think in the end it should "look" like this: (for line 3)
%name_of_hash = (
key1 => ["value1"], ["value3"],
key2 => ["value1"], ["value4"]
);
The file uses ";" as a delimiter and in field 4 you have information
about how many key;value-pairs there will be.
I hope I could make myself clear about the problem. I want to read a
file line by line and compare it with some other file. But at the
moment I don't know how to store the information in a hash!
If someone had an idea that would be great!
Greetings
Chris
I have a problem with a file. It looks like this
;r;information;more_info;1;key1;value1;
;s;more;more;2;key1;value1;key2;value2;
;t;info;and;4;key1;value1;key2;value1;key1;value3;key2;value4
I have to extract the information in key and value of each line and
compare it to some information in another file.
I would like to read the file and store the key;value pairs into a hash
and then compare it later on with the other information I have.
As you can see (hopefully) in my example (i.e. line 3) I have some keys
that are used twice (or more often). My suggestion would be an hash of
arrays.
I think in the end it should "look" like this: (for line 3)
%name_of_hash = (
key1 => ["value1"], ["value3"],
key2 => ["value1"], ["value4"]
);
The file uses ";" as a delimiter and in field 4 you have information
about how many key;value-pairs there will be.
I hope I could make myself clear about the problem. I want to read a
file line by line and compare it with some other file. But at the
moment I don't know how to store the information in a hash!
If someone had an idea that would be great!
Greetings
Chris