In addition to the comment made by the other monks, I'd like to describe a basic locigical flaw with this code. By using foreach my $row_ref (@$dataOut->fetchrow_array) you are actually iterating over columns, not rows. Changing this to use fetchrow_arrayref only changes it to be a foreach over a list with only one value (doesn't make any sense to do that). What you really meant to use there was fetchall_arrayref. This will return an array of arrays with all the data retrieved by your SQL query.

Update: After reading arturo's response, I'd like to add the following: using while(my @row = $dbh->fetchrow_array) is more memory efficient than using foreach my $row_ref ($dbh->fetchall_arrayref) but fetchall_arrayref may be faster (I'm not sure, it would depend on which DBD module was being used, you'd have to benchmark it). To speak to arturo's recomendation of using fetchrow_hash, it does make the code more maintainable, but less memory efficient, so it really depends on which is more important to you. You can achive the same effect as using fetchrow_hash using fetchall_arrayref by passing an empty hash ref in as an argument to the method.
HTH, Cheers


A truely compassionate attitude towards other does not change, even if they behave negatively or hurt you

—His Holiness, The Dalai Lama


In reply to Re: accessing data in DBI object by JediWizard
in thread accessing data in DBI object by arcnon

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.