foreach my $worksheet (...) { ... foreach my $row (...) { ... if (...) # filter out unwanted data, including header { send_data(...); # send data extracted from the spreadsheet } } } send_data(zipcode => 'DONE'); # NOW you're done!