$count = 0; $test_num = 0; # Finds district for all stores foreach $dist_fld (@all_stores) { if ($count < 998) { my $new = $dist_fld.","; print "$new\n"; push(@store_get_dist1,$new); $test_num + 1; } if ($count < 1998) { my $new = $dist_fld.","; print "$new\n"; push(@store_get_dist2,$new); $test_num + 1; } if ($count < 2998) { my $new = $dist_fld.","; print "$new\n"; push(@store_get_dist3,$new); $test_num + 1; } } print "Number of queries needed: $test_num\n"; for ($i = 1; $i < $test_num; $i++) { 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 $get_district = "SELECT distinct(DIST_I)\n". "FROM BCE_STORE\n". "WHERE LOC_I in (@store_get_dist${i})"; $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"; } }