#More code is here, this is just to explain my problem... $sth->execute() || die $sth->errstr; while (my $pointer = $sth->fetchrow_hashref){ $N_NUM = &cleaner ($pointer->{'number'}); push @array,$N_NUM; &total(@array); #Print HTML print ""; # My problem is here cause I can only get the value of this varialbe $results when I have send the array @array to the SUB TOTAL &total; print " "; } End while sub total { my $all_info = shift (@_); # gets values passed by @array, it has all the Numbers found on DB my @info = split/ /,"$all_info"; # It checks a DB table and if the number is found here it should send back a value of "FOUND" or "NOT FOUND" code would go here getting the values in here is not a problem... ok, let say that my final result is; my $results="FOUND"; return; }
  Products$results