in reply to Re: How not to remove trailing empty strings from an array
in thread How not to remove trailing empty strings from an array

My actual fix was

pop @msgstr while @msgstr && !length($msgstr[-1]);