in reply to Reading a MySQL table into an array

It seems to me that you are :

A simpler solution should be:

my $tables = $dbh->selectcol_arrayref("SHOW_TABLES") or die $DBI::errstr;

This one, and many more are shown in DBI Recipes.

Be sure to understand the various idioms before using them. One introduction to what to get from a database is shown in The fine art of database programming.

And, don't forget to "use strict" and warnings.

Replies are listed 'Best First'.
Re^2: Reading a MySQL table into an array
by rvosa (Curate) on Jul 30, 2005 at 15:25 UTC
    use SQL; my @tables; my $temp; SQL::Connect "debloat", "localhost"; SQL::xqt "SHOW TABLES"; my $i = 0; while ($temp = $SQL::sth->fetchrow_arrayref){ $tables[$i] = $$temp[$i]; } foreach (@tables) { print "$_\n"; }
    If this is the exact same code you're using it would seem that you only get one entry because you don't update $i++.
      Sorry - I was trying to cut my code down to the minimum & cut too much! I'll check this out (as I said in another reply, my intention is to understand), but I have deleted some of my code after following RNahi's advice and getting a working solution.

      Regards,

      John Davies
Re^2: Reading a MySQL table into an array
by davies (Monsignor) on Jul 30, 2005 at 15:23 UTC
    Thanks. I couldn't immediately see how to do what I want with your solution, but the DBI recipes reference gave me everything I needed. I'll keep trying with your advice, though, as the purpose is to understand (the live DB & VB front end has been supporting about 20 users for about 18 months). I'm still rather mixed up about the array instructions, but I expect that I'll be able to sort myself out with more reading.

    I am using strict, warnings and diagnostics in all my files. If I didn't mention it in my somewhat rambling post, my apologies.

    Regards,

    John Davies