use strict; use warnings; my @all_stores; my @store_get_dist; my $dbv; my $count = 0; my $test_num = 1; # Finds district for all stores foreach my $dist_fld (@all_stores) { $test_num++ if ++$count =~ /(\d*)998/; my $new = $dist_fld.","; print "$new\n"; push(@{$store_get_dist[$test_num]},$new); } print "Number of queries needed: $test_num\n"; for my $i (1 .. $test_num) { my $last_one = pop @{$store_get_dist[$i]}; #error occurs here chop($last_one); push (@{$store_get_dist[$i]}, $last_one); #error occurs here # GRAB ALL STORE, DISTRICT, REGION AND GROUP info my $get_district = "SELECT distinct(DIST_I)\n". "FROM BCE_STORE\n". "WHERE LOC_I in (@store_get_dist${i})"; my $grab_dist = $dbv->prepare("$get_district"); ### Execute the statement in the database $grab_dist->execute; print "$get_district\n"; while ( my $row = $grab_dist->fetchrow( ) ) { print "$row\n"; } }