in reply to HTML::Entities not encoding @ or .

The default set of characters to encode are control chars, high-bit chars, and the <, &, >, and " characters.
@ and . are not on the list. Try
encode_entities($a, "\000-\377");