Well I came up with this:
open(INF,"flat.txt");
my(@wlines) = <INF>;
close(INF);
foreach $t(@wlines) {
$d .= $t;
};
@each_line = split(/\n/,$d);
$cut =0;
foreach $word_group(@each_line){
@{$words[$cut]} = split(/\¦/,$word_group);
$cut++;
}
a1¦a2¦a3...
b1¦b2¦b3..
and so on...
open (FP, "flat.txt");
chomp(@lines=<FP>);
close (FP);$tmp1=0;
$tmp2=0;
foreach $i (@lines) {
@temp=split(/\¦/, $i);
foreach $foo (@temp) {$words[$tmp1][$tmp2++]=$foo;}
$tmp2=0;
$tmp1++;
}
I'm not sure if it's an improvement - I've not benchmarked it - but it's another way.
Your @{$words[$cut]} is an interesting construct, I must look into that...
You thought me something,. It looks like my scriptlet could be weeded down.
This:
foreach $t(@wlines) {
$d .= $t;
};
@each_line = split(/\n/,$d);
$cut =0;
foreach $word_group(@each_line){
could be replaced with this:
$cut =0;
foreach $word_group(@wlines){
I didn't know that perl will automatically divide up an array along the newline character. That is cool.