This line works fine under linux :
PGPASSWORD=***** psql --username=**** -h ***** -d **** -p **** -P pager=off -t --csv -c "select \"Nom\", \"Path\" from \"vVMware-Vms\" where \"Date\" = '2025-07-22';"
When I try to embed it in a perl script, it outputs me an error. Tried many separators (single-quote, double-quote) without success.
In my perl script, I create my string wih this line (but tried many other things) :
$Cmd = qq(PGPASSWORD=**** psql --username=**** -h ***** -d ***** -p **** -P pager=off -t --csv -c "select \"Nom\", \"Path\" from \"vVMware-Vms\" where \"Date\" = '2025-07-22';");
When printing it (with Dumper), I got :
$VAR1 = 'PGPASSWORD=**** psql --username=**** -h **** -d **** -p **** -P pager=off -t --csv -c "select "Nom", "Path" from "vVMware-Vms" where "Date" = \'2025-07-22\';"';
And when running, I got this message :
ERROR: syntax error at or near "-"
LIGNE 1 : select Nom, Path from vVMware-Vms where Date = '2025-07-22';
^
And of course, I cannot change the table name and don't want to use DBI module.
Any clue ?
psqlinstead of DBI makes it less portable, not more. You now requireshandpsqlon top ofperl.