http://www.perlmonks.org?node_id=11108337


in reply to PostgreSQL connection set in UTF8

Your code doesn't open a connection to Postgres, it opens a pipe to the postgres client psql. You might try adding the encoding layer to the pipe by specifying
open my $db, '|-:encoding(UTF-8)', '/opt/postgresql-9.4/bin/psql -h' o +r die $!;

but switching to DBI and DBD::Pg seems like a much better approach.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]