in reply to PostgreSQL connection set in UTF8

Try binmode: binmode DB, ':utf8';

But you should probably be using Text::CSV (or DBD::CSV) and DBI for this, instead of opening a pipe to psql. What happens if a row fails to insert due to a constraint violation in your current code? DBI will report the error.