++AnomalousMonk explained the "why".

Here's something you can do to get the string in the format I think you want: the String::Interpolate module allows you to pass a string with character escapes and get back the string that I believe you desire.

C:\usr\local\share>perl use strict; use warnings; use v5.10; use String::Interpolate qw/interpolate/; my @lines = <DATA>; for my $line ( @lines ) { chomp $line; say "data line is *$line*"; my $real = interpolate($line); say "real line is *$real*"; } __DATA__ hello\ngoodbye good\nevil yes\nno
yields
data line is *hello\ngoodbye* real line is *hello goodbye* data line is *good\nevil* real line is *good evil* data line is *yes\nno* real line is *yes no*

note: I've never used it before today; I found it via a quick search, and its description and above behavior seemed right.

Also, I don't have the Programming Perl to check page numbers, but "translation escapes" sound like escapes that are only available to the regex substitution engine and not to normal strings, so those will likely not be available even in String::Interpolate (unchecked).


In reply to Re: Can't get \n or other character/translation escapes to interpolate if originally read from a data file by pryrt
in thread Can't get \n or other character/translation escapes to interpolate if originally read from a data file by davebaker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.