I have a bunch of Perl scripts that have recently stopped working. I have narrowed the problem down to this: when I connect to a postgresql database from a perl script, it attempts to use the wrong username and the connection fails.
E.g. if I am logged in as someuser:
someuser$ psql -l
List of databases
Name | Owner | Encoding
-----------------+----------+----------
one | someuser | UTF8
two | someuser | UTF8
the output is as expected.
But if I attempt the same from within Perl:
someuser$ perl -e 'system("psql -l")'
psql: FATAL: role "anotheruser" does not exist
The same thing happens when using the DBI module; this is just the simplest way to reproduce the problem. Obviously the psql
executable is picking up the wrong username when run from within Perl; any ideas how this is happening?