"""Within POSIX bracket expressions, the dot character matches a literal dot. For example, a.c matches "abc", etc., but [a.c] matches only "a", ".", or "c"."""
My bad.
if("%{User-Name}" =~ /\\\\?([^@\\\\]+)@?([-[:alnum:]._]*)?$/) {
I'm not that good with POSIX regex, but shouldn't it beAFAIK the dot "." means "any char" so I think it needs to be escaped.
if("%{User-Name}" =~ /\\\\?([^@\\\\]+)@?([-[:alnum:]\._]*)?$/) {