in reply to Spreadsheet::WriteExcel Write through scalar variable

Is there maybe whitespace at the end of $txt? The chomp removes one newline character at the end, but maybe the cell value contains \r\n and not \n. Try printing out the value using Data::Dumper:

use Data::Dumper; $Data::Dumper::Useqq= 1; $txt= "foo\r"; print Dumper $txt; # $VAR1 = "foo\r";

Replies are listed 'Best First'.
Re^2: Spreadsheet::WriteExcel Write through scalar variable
by DVCHAL (Novice) on Oct 31, 2013 at 08:48 UTC

    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.

      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.