I am currently developing a script in PERL it works but I would like to append the contents to the CSV file whenever the script is executed <pre><code>print "Enter number of days: "; my $var = &lt;STDIN&gt;; my $SQL = "COPY (SELECT * FROM Parent WHERE StartDate &lt; NOW() - INTERVAL '$var days') TO '/home/username/Desktop/new1.csv' WITH CSV"; my $sth = $dbh-&gt;prepare($SQL); my $rv1 = $dbh-&gt;do($SQL) or die $DBI::errstr; </code></pre>