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 :)


In reply to Re^3: Direct to spreadsheet by McDarren
in thread Direct to spreadsheet by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.