The @sql is used because a sql string which consists of many parts including a "select * from" is built further up the code.
Okay, but it still doesn't make sense. $sth->prepare accepts just a single parameter (an SQL statement string). So as far as I can see, the only way your code can possibly work is if you are passing a single element list. In which case, you should be assigning your SQL string to a scalar variable (ie. $sql).
However, that doesn't really address your current problem. If reading your entire result set into a hashref isn't an option, then you probably want a LoL
In any case, your current use of selectall_arrayref fetchrow_arrayref is un-necessary. You could simply do something like:
while (@row = $sth->fetchrow_array) {
...and then the line
print TXT "\nBOR $data->[3]|$data->[2]|$data->[9]|$data->[10]|$data->
+[4]|$data->[13]";
..simply becomes
print TXT "\nBOR ", join("|", @data[3,2,9,10,4,13]);
..or as GrandFather suggested
push @data, "\nBOR ", join("|", @data[3,2,9,10,4,13]);
Apologies if I'm not appearing very helpful. But as I said earlier, I'm finding it difficult to visualise the solution without actually seeing what your data looks like. Perhaps some more experienced monk will chip in and offer their advice :)
Cheers,
Darren :)
|