in reply to heredoc and Carriage return

Try:

my $win = << "__WIN__"; line 1\r line 2\r __WIN__

Using a double quote around the heredoc tag will cause the heredoc to be interpolated. That is, the "\r" will be interpolated as a CR (U+000D).