To combine the points that rjt and GrandFather made, it'd be best if you inspect your string with Devel::Peek and your file with hexdump; I gave an example here.
In reply to Re: String differs from printing to STDOUT and printing to file
by haukex
in thread String differs from printing to STDOUT and printing to file
by cboesch
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |