in reply to use of last

Actually last will only work on loops. A single block, without any kind of flow control (if, do while, for) counts as a loop that executes only once. So

{ open my $fh, "<", "some_file" or last; }
Will work, and you can make it work with your code by doubling the curly brackets:
if (/VALID/) {{ # First bracket is for the if, second is for a loop-like block open my $fh, "<", "some_file" or last; }}

last will never allow you to exit an if-block, because it is often used in constructs such as:

while (<>) { if (/INVALID/) { last; } }
Note that it's always possible to name the while loop to provide the name to last and make it clearer what you are leaving.

Edit: completed my last sentence (apparently I forgot what I was saying mid-sentence), and added a condition after the if, so that the code doesn't look so odd.

Edit: BTW, I think that karlgoethebier's version is easier to read.