in reply to do-until inside while loop control
Check out the redo command, which allows you to go back to the top of a loop without re-evaluating the conditional (in your case, without reading another line in while (<data_file>)) so $_ will still contain the line with regex2 in it.
In Section
Seekers of Perl Wisdom