Sorry, that package reads from a specified filename and the subroutine is as following:
sub read_file
{
my $self = shift;
my $filename = shift;
my $i = 0;
my $header_parse = 0;
my $header_name = 0;
open FILE, "<$filename" or die "cannot open $filename for input\n";
while (my $line = readline (*FILE))
{
# Strip newlines and leading / trailing whitespace
for ($line)
{
chomp;
s/^\s+//;
s/\s+$//;
}
# Skip blank lines and comments
next if ($line !~ m/\w/ || $line =~ m/^#/);
if ($line =~ m/^\[\s*([\w|\s]+)\s*\]/)
{
$header_name = $1;
$header_parse = 1;
}
elsif ($header_parse)
{
$self->{HEADERS}{$header_name} = $line;
$header_parse = 0;
}
else
{
my @data = split $self->{REGEX}, $line;
$self->{DATA}[$i++] = \@data;
}
}
close FILE;
}
The first matrix/table in a .csv file I need to read/loop from is as following:
POSITION R CH TW TH
1 2 2.0 60 100
2 4 2.5 61 100
3 6 2.8 62 88
.. .. .. .. ..
N 40 0.9 74 18
while the structure of one of the J tables linked to the first table through the TH array is as following:
Header 100 (or a value from 88 .. to 18, referring to TH in the first table)
A B
-180 0.1
.. ..
M 0.9
I don't know how to parse the header (in the first table) in one of the J tables with the corresponding header.
|