my ($category_list) = getCategories(); ### Trying to figure out how to loop through $category_list for (my $search_total=0; $search_total<=$#$category_list; $search_total++) { # Do something with these: # $category_list->[$search_total]->{category_id} # $category_list->[$search_total]->{parent_id} # $category_list->[$search_total]->{category_name} } ### Used to do a single select to grab all categories sub getCategories { my ($results_data) = []; my $row = 0; my $sql = qq~SELECT category_id, parent_id, category_name FROM ss_catalog_categories~; my $sth = $dbh->prepare($sql); $sth->execute; while (my @results = $sth->fetchrow_array()) { $results_data->[$row]->{category_id} = $results[0]; $results_data->[$row]->{parent_id} = $results[1]; $results_data->[$row++]->{category_name} = $results[2]; } $sth->finish; return ($results_data); }