in reply to Re^2: How to read multiple tables into arrays
in thread How to read multiple tables into arrays

The point about the query that Corion suggested is that you get a single stream of rows returned from the database, each row contains a college name, a department name, an "itstuff" name, and an IP address, and you get one row for every IP address that exists in your IP table.

From that single stream of rows, you can split the results into multiple arrays if you want to (one for each college, or one for each college/department, or one for each college/department/itstuff) -- although it might be better to arrange them into a hash structure -- but in any case, you get to process all the data in a single loop over the query output. Something like this:

my $sql = "select ..."; # query string as suggested by Corion my $sth = $dbh->prepare( $sql ); $sth->execute; my $row_data = $sth->fetchall_arrayref; # gets all data from query my %data_structure; for my $row ( @$row_data ) { my ( $college, $dept, $it, $ip ) = @$row; $data_structure{$college}{$dept}{$it} = $ip; }
You haven't said yet what you really want to do once you have the data from the tables, but there's a good chance that a hash structure will be more useful than a bunch of arrays.

BTW, you said at the top that you had 5 tables, but you only talk about 4. If there really are 5, you should be able to figure out how to extend Corion's query and the code snippet shown here.

Also, do please look at some of the links provided on the posting form: Writeup Formatting Tips, How do I post a question effectively, and Markup in the Monastery -- it's for your own good.