in reply to Until there's nothing but spaces?

assuming that you're reading from the file into the variable $line, you may want to change that line to
print $line until(!($line =~ /\s+/))
. However this doesn't look like this is quite what you want. That regex will match every line in the text (\s matches newlines). I'd switch your regex to be looking for word characters, so that once the line doesn't have any word characters, you exit your loop. I would do something like this:

use strict; use warnings; my $line; open IN,"lines.txt"; while($line = <IN>) { print $line unless(!($line =~ /\w+/)); }