Convert A Tsv Into A Perl Data-structure

This is a really simple project where you will read in a tab separated file and dynamically generate a perl data-structure. It should really be a 30 minute job, but I just haven’t worked with this data-structure before. The data-structure is as follows.

my (at)set = (
[0,0] => [0],
[0,1] => [1],
[1,0] => [1],
[1,1] => [0],
);

The only gotcha is that it needs to support a variable number of columns in the array. For example, if I have 3 columns, then it will look like

my (at)set = (
[0,0,1] => [0],
[0,1,1] => [1],
[1,0,1] => [1],
[1,1,0] => [0],
);

I have attached an Example1.txt with a corresponding Example1.pl and this might be how the code would look if we were fixed to the number of Feature Columns the text file had. However, we want to support files that have as many columns as possible.

Leave a Reply

Your email address will not be published. Required fields are marked *