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

Thanks your prompt reply Corion, I got the print result as "bite\r\a"

.

How to remove the trailing '\r' and '\a'

Thanks in Advance.
  • Comment on Re^2: Spreadsheet::WriteExcel Write through scalar variable

Replies are listed 'Best First'.
Re^3: Spreadsheet::WriteExcel Write through scalar variable
by Corion (Patriarch) on Oct 31, 2013 at 10:24 UTC

    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.