what you have there should correspond only to a fine. the regex will match any template greeting event, so as long as it sees hello somewhere in $ var it will match
On the other hand, if you want to strictly abide by what you ignore, you must bind your string from start to finish
if($var =~ m/^\s*hello\s*$/) {
}
and if you have a few words in your template
if($var =~ m/^\s*hello\s+world\s*$/) {
}
\ s * 0 , \s + 1 . ^ , $ .