in reply to Sensing of Null character

Instead of chopping only if it's there, your could do

$variable =~ s/\0\z//;

assuming that ^@ is the visual 'control character' representation of the zero byte that you get in some editors/tools...