A sample log file somewhat look like this:
Note that --
1) In each row, the elements are delimited by ':';
2) The number of elements in each row may very, i.e. m, n, i, & j are integers and m != n != i != j.
How to construct a multi-dimension hash whose keys are the elements in rows denoted as xij and values are the last element in each row.
For instance, if a simplified log file was like:
then the hash would be like:
I guess the implementation should use recursive call. But I don't know how to implement it.
Thanks for your kind help.
Code:
x11:x12:x13:...:x1m:value1
x21:x22:x23:...:x2m:...:x2n:value2
x31:x32:x33:...:x3i:value3
x41:x42:x43:...:x4i:...:x4j:value4
Note that --
1) In each row, the elements are delimited by ':';
2) The number of elements in each row may very, i.e. m, n, i, & j are integers and m != n != i != j.
How to construct a multi-dimension hash whose keys are the elements in rows denoted as xij and values are the last element in each row.
For instance, if a simplified log file was like:
Code:
x11:x12:x13:value1
x21:x22:x23:x24:value2
then the hash would be like:
Code:
my %cache => (
'x11'=>{
'x12'=>{
'x13'=>value1,
},
},
'x21'=>{
'x22'=>{
'x23'=>{
'x24'=>value2,
},
},
},
},
);
I guess the implementation should use recursive call. But I don't know how to implement it.
Thanks for your kind help.