in reply to Re^2: Creating an array of structures?
in thread Creating an array of structures?
I know the "#push @{list_of_object},$object_name, $object_type;" line is wrong, but am not sure how to populate what I want to be a 2D array (@list_of_objects) with the two variables returned for each row ($object_name and $object_type). Additionally, once this occurs, how will I be able to reference just the $object_name from this array for each element in the array to then search a document for each $object_name. Is it a case of using foreach loops to reference each dimension in the array? Such as(extreme pseudocode to follow:use strict; my ($object_name, $object_type, $module_type, @list_of_objects, $database, $userid, $passwd); $database = 'DBI:Oracle:tdtxtasd'; print "Please enter your username:"; $userid = <STDIN>; chomp($userid); print "Please enter your password:"; $passwd = <STDIN>; chomp($passwd); use DBI; my $dbh = DBI->connect($database, $userid, $passwd) or die "Couldn't connect to database: " . DBI->errstr; my $sth = $dbh->prepare('SELECT object_name, object_type FROM user_obj +ects WHERE object_type = ?') or die "Couldn't prepare statement: " . $dbh->errstr; $module_type = "PROCEDURE"; my $rc = $sth->execute($module_type); while (($object_name, $object_type) = $sth->fetchrow()) { #push @{list_of_objects},$object_name, $object_type; print "$object_name $object_type\n"; }; $dbh->disconnect;
I realize this is a long post. I hope I get my point across. Let me know what you think. Thanks.foreach i (1....n) { foreach j (1,2) { $object_name = @list_of_values[i][2]; } };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Creating an array of structures?
by Tanktalus (Canon) on Mar 08, 2005 at 18:24 UTC |