Unfortunately this would also match "TEST SENTENCE " (note the trailing whitespace).

The following test illustrates another method:

#!/usr/bin/perl -w
my $data = <<'EOF';
This is a sentence. THIS \
IS A SENTENCE. This is \
a SEQUENCE OF UPPER WORDS and \
this is not.
EOF
while ( $data =~ m/(\b(?:[A-Z]+(?:\s+[A-Z]+)*)+\b)/g ) {
print "Upper Sentence: \"$1\"\n";
}

I upvoted your post above, but still your regex m/(\b(?:[A-Z]+(?:\s+[A-Z]+)*)+\b)/g made me squirm. Whenever I see sequences of nested quantifiers like that:+)*)+ I get uncomfortable, remembering various pathelogical cases I've constructed in the past.

To that end, I thunk again, and came up with this which I believe meets the 'spec', whilst avoiding the nested quantifiers;

I may be wrong but I'm guessing from the backslashes in your heredoc that you want $data to contain a single-line string. I don't think what you have written will achieve that. Single quotes result in literal backslashes along with the newlines in the string and double quotes don't seem to escape the meaning of the newline. Doing a global substitution is one way of getting a single line. Consider the following code