CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: DBI:
Loading MySql records into an array


New User

Aug 25, 2008, 5:28 PM

Post #1 of 2 (3222 views)
Loading MySql records into an array Can't Post

I am having trouble making this work. I have just recently started attempting using SQL in my Perl programming and it shows Blush

I am trying to load a selected set of records from MySQL into an array. Each record has 12 fields so what I am expecting to happen is to have an array with a certain number of rows (say 10) and 12 columns.

The code I use is:

@sql_timedevents = ();
$sql_timedevents_handle = $sql_handle->prepare('SELECT * FROM events_list where xtype="timed"');
while (my @ary = $sql_timedevents_handle->fetchrow_array()) {
print_log @ary;

This gives me the 10 rows but when I try to printout the array I have references to the columns and not the values. If I take away the [] around the @ary I get 120 rows.

What I need to accomplish is to be able, later in the code, to loop through the array and use the various field data stored in it.

This is probably real simple but I can see it, would appreciate any insights!

Thanks, Peter


Aug 25, 2008, 6:56 PM

Post #2 of 2 (3220 views)
Re: [starcastle] Loading MySql records into an array [In reply to] Can't Post

foreach my $rows (@sql_timedevents) { 
foreach my $inner_rows (@{$rows}) {
print "$inner_rows\n";



Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives