in reply to Re^2: Spreadsheet::WriteExcel Write through scalar variable
in thread Spreadsheet::WriteExcel Write through scalar variable

I would remove all whitespace, or maybe even all non-printable characters from the end of the string:

$txt=~ s!\s*$!!; # remove all whitespace

... or alternatively

$txt=~ s![^A-Za-z0-9]*$!!; # remove everything except characters and d +igits at the end

Note that the second approach will also remove trailing dashes and other stuff like that.