#!/usr/local/bin/perl -w # General perl libraries use strict; use English; use DBI; # output file my $outputfile = $ARGV[0]; open(FILE, ">>$outputfile") || die "Error: Can't open $outputfile for writing: $!\n"; my $dbh = DBI->connect("dbi:Pg:database;host=dbhost", "user", "userpwd", {AutoCommit => 1}); my $sth = $dbh->prepare("Tried and tested SQL query that simply returns a list of id numbers"); $sth->execute(); #print values while(my $ref = $sth->fetchrow_hashref()) { print FILE "$ref->{'id'}\n"; } $sth->finish(); # disconnect from database $dbh->disconnect(); SendtoPrepare($outputfile); ################################################################### sub SendtoPrepare { my($file) = @_; print "$file\n"; open(INFILE, "$file") || die "Error: Can't open $file for reading: $!\n"; my @code = ; print "@code\n"; }