Regarding the idiom eval ...; if ($@) ..., see for example Bug in eval in pre-5.14 or the "Background" section in Try::Tiny. The better idiom is eval "...; 1" or handle_error($@). And in this case I'd suggest eval BLOCK instead of eval STRING so that syntax errors can be caught at compile time.
Also, in "say "Unable to connect to '$host'. $!"", I think that should be $@ instead of $! (at least per the documentation of Net::SMTP).
Regards,
-- Hauke D
Update: s/patter?n/idiom/
In reply to Re^2: instantiating an smtp object
by haukex
in thread instantiating an smtp object
by Aldebaran
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |