Since you are only testing once, you do not need the g modifier.
// will match everything. Hence $x!~// will always return false.
/\s+/ will match if your string contains at least one space. Hence $x!~/\s+/ will return false if your string contains at least one space.
Changing $x!~/\s+/ to $x!~/\S+/ will return true when the string does not contain at least one non-whitespace character, and hence will make your test work.
You could use anchors (^ and $) and * to do what you intend as well with $x=~/^\s*$/. This translates as requiring that between the start (^) and end ($) there is exactly 0 or more (*) whitespace characters (\s).
I would suggest reading through perlretut to gain familiarity with this tool.