Greetings Wise Monks:
I have a program that in part uses a database object to query a database and return it's contents in a table to the originating program.
The problem I'm having is that I then want to loop through all of the rows in that table, which of course can vary. The code I was attempting to use causes a "Can't use string ("2") as an ARRAY ref while "strict refs" in use at..." error.
2 is of course, the correct number of rows in my test scenario. What I'm not grasping is why if perl knows the value, is it not able to insert it into the variable?
Any suggestions are helpful.
my $Table = $dbObject->getTable;
my $tableDimensions = @$Table;
my $numRows = $tableDimensions->[0]; #the error occurs here
for (my $timesThru=0; $timesThru<=$numRows; $timesThru++) {
If you give a man a fish he will eat for a day.
If you teach a man to fish he will buy an ugly hat.
If you talk about fish to a starving man, you're a consultant.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.