Considering your responses further down in the thread, where you say you're actually looking to store sequences of search strings and replacements, I think perhaps it might be better to look at existing data serialization formats instead of inventing your own. For example, JSON is very common nowadays, or YAML is sometimes a bit more human-readable. In addition, since your search strings appear to be fairly similar, it's worth investigating whether a regex or two can match your search strings with more flexibility instead of listing all the search strings.

use warnings; use strict; use JSON::PP; use YAML::PP; my $data = [ { search=>"Reach Holly Smith for help by sending an email\nto holl +ysmith\@nosuchdomain.com.", replacement=>"For more information, conta +ct Holly Smith." }, { search=>"For more information, contact Holly Smith at\nhollysmit +h\@nosuchdomain.com.", replacement=>"For more information, contact Ho +lly Smith." }, { search=>"For more information, contact Holly Smith at (800) 555- +1212 or\nvia email to hollysmith\@nosuchdomain.com", replacement=>"Fo +r more information, contact Holly Smith." }, ]; my $json = JSON::PP->new->pretty; print $json->encode($data); my $yaml = YAML::PP->new; print $yaml->dump_string($data); __END__ [ { "search" : "Reach Holly Smith for help by sending an email\nto h +ollysmith@nosuchdomain.com.", "replacement" : "For more information, contact Holly Smith." }, { "replacement" : "For more information, contact Holly Smith.", "search" : "For more information, contact Holly Smith at\nhollys +mith@nosuchdomain.com." }, { "replacement" : "For more information, contact Holly Smith.", "search" : "For more information, contact Holly Smith at (800) 5 +55-1212 or\nvia email to hollysmith@nosuchdomain.com" } ] --- - replacement: For more information, contact Holly Smith. search: |- Reach Holly Smith for help by sending an email to hollysmith@nosuchdomain.com. - replacement: For more information, contact Holly Smith. search: |- For more information, contact Holly Smith at hollysmith@nosuchdomain.com. - replacement: For more information, contact Holly Smith. search: |- For more information, contact Holly Smith at (800) 555-1212 or via email to hollysmith@nosuchdomain.com

In reply to Re: Can't get \n or other character/translation escapes to interpolate if originally read from a data file by haukex
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.