我试图在二维数组中读取一个巨大的CSV文件,必须有一个更好的方法来分割线并一步保存在二维数组中:s干杯
my $j = 0;
while (<IN>)
{
chomp ;
my @cols=();
@cols = split(/,/);
shift(@cols) ; #to remove the first number which is a line header
for(my $i=0; $i<11; $i++)
{
$array[$i][$j] = $cols[$i];
}
$j++;
}
Run Code Online (Sandbox Code Playgroud)