in reply to Re: extracting single column
in thread extracting single column
Better:my $column_separator = ",";
...imaging someone wants to use "." as separator.my $column_separator = qr/,/;
Don't write numbers as text, write them as numbers (cut away those " chars).my $column_number = "3";
Loading the whole file into memory might not be that good idea, imagine it's a 10 GB file. Why not parse it line-by-line?
open(FILE,"<","$file"); while (<FILE>) { my @columns = split(/$column_separator/); print $columns[$column_number],"\n"; } close FILE;
|
|---|