in reply to regexp for blank lines

Your regex matches one or more whitespace, so it should match the whitespace between words. Changing it to /^\s+$/ anchors it at the start and end of the line, which works. Or you can use:

next unless $line =~ /\S/;

"next unless the line contains a non-whitespace character"

qq