It's probably easier and cleaner to just write a one-off test rather than working within this fixed framework, but you could use this to check if your test string contains only whitespace:
my $regex = q|(??{'\s{' . length($tests) . '}'})|;
This requires you to include use re 'eval'; at some point in scope. It also requires that the name of of the variable being tested is literally $tests - if not, you need to modify the string accordingly.
How it works:
The expression uses Perl code executed at matching time - see (??{ code }) in perlre. The string literal stored in $regex is (??{'\s{' . length($tests) . '}'}). When the regular expression is executed, Perl concatenates '\s{', the length of the variable $tests and '}'. The resulting regular expression requires that the string in question match exactly as many whitespace characters as there are characters in the string, i.e. contain only whitespace. You should also note that this opens up some security holes in Perl, as discussed in (??{ code }) and in A bit of magic: executing Perl code in a regular expression from perlretut.