in reply to to run a command from $ shell in perl program
Have you looked at DBI and DBD::Pg? Do they allow you to do the database stuff you need without spawning a shell process?