I think the error is at the following line:
$worksheetout->write_col( 0, 0, @$indata ); # Should be: $worksheetout->write_col( 0, 0, $indata );
The write_col() method takes an array_ref as the third argument.

Update: In relation to your question "what is the best way to track down issues when the error comes from the module itself?".

In your particular case you were a little unlucky. WriteExcel checks that the required parameter is an array_ref and croaks an error from the point of view of the calling program. Something like this:

Not an array ref in call to write_col() at /tmp/pm876841.pl line 4 +1
Unfortunately, once you had (accidentally) flattened the first level of the array ref the next element was also an array ref and the check was validated so the module didn't report the error back at the right place.

The way that I tracked this down was the way I always do it. With the perl debugger running under Emacs. I commented out the includes that I didn't have and replaced your DB call with a function returning a simple array ref.

Once the program compiled I ran through it in the debugger until I hit the write_col() line where the error was thrown.

P.S.: you probably have the same error here.

$worksheetout->write_col( 1, 0, @$sqldata );

--
John.


In reply to Re: Spreadsheet::WriteExcel error by jmcnamara
in thread Spreadsheet::WriteExcel error by ag4ve

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.