I need to read a 200mb "space"-separated file line-by-line and collect its contents into an array.
Every time I run the script, Perl throws an "out of memory" exception, but I don't understand why!
Some advice please?
#!/usr/bin/perl -w
use strict;
use warnings;
open my $fh, "<", "../cnai_all.csd";
my @parse = ();
while (<$fh>) {
my @words = split(/\s/,$_);
push (@parse, \@words);
}
print scalar @parse;
the cnai file looks like this: it contains 11000 rows and 4200 values, seperated by "space", per line.
VALUE_GROUP_A VALUE_GROUP_B VALUE_GROUP_C
VALUE_GROUP_A VALUE_GROUP_B VALUE_GROUP_C
VALUE_GROUP_A VALUE_GROUP_B VALUE_GROUP_C
VALUE_GROUP_A VALUE_GROUP_B VALUE_GROUP_C
The code above is just a stripped down sample.
The final script will store all values in a hash and write it to a database later .
But first, I have to solve that memory problem!