while (....) { # Then for each reading, get the values my @data_fields = get_my_data(); # and write them to the table $ST->execute(@data_fields); }