Better to do use warnings than use diagnostics. Diagnostics tends to be pretty dumb and the error messages are overly verbose and are harder to control.
Your code is a good example of this.
Comment on Re: Strict error on var when using Mail::SendMail