in reply to Odd symbols in read file function?
Maybe this particular file can be split on TAB correctly, but even then, it is not CSV. (The C stands for Comma). There are however several CSV modules that can perfectly deal with TCV data. You might want to try either of these.
using DBD::CSV (utf8 encoded tab-separated .txt files):
use DBI my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { f_ext => ".txt/r", f_encoding => "utf-8", csv_sep_char => "\t", # more options available RaiseError => 1, }); my $sth = $dbh->prepare ("select * from test"); $sth->execute; while (my @row = $sth->fetrow_array) { # do something with the fields }
Using Text::CSV_XS:
use Text::CSV_XS; my $csv = Text::CSV_XS->new ({ binary => 1, auto_diag => 1, sep_char = +> "\t" }); open my $fh, "<:encoding(utf-8)", "test.txt" or die "test.txt: $!"; while (my $row = $csv->getline ($fh)) { # do something with @$row } close $fh;
|
|---|