Lot's of interesting stuff in this thread, but - oddly enough - I didn't see anyone mention the first thing that came to mind for me when I read the OP: use "paragraph mode" when reading from __DATA__, and have the various blocks of text separated by blank lines, with some simple, basic syntax that makes it easy to parse each block in a consistent way. Something like this:
#!/usr/bin/perl use strict; use warnings; my %structure; { local $/ = ""; # input record separator = empty string for "parag +raph mode" while (<DATA>) { s/^(.*)\n//; # first line is key string $structure{$1} = $_; } } print "key: $_ / value:\n$structure{$_}\n----\n" for ( sort keys %stru +cture ); __DATA__ first_key Here's some data to go with the first key key_3 Third key gets this part key number 2 This element of %structure has spaces in the hash key.
(Note that in this example the final new-lines are retained in the values.)

UPDATED to localize the use of paragraph-mode.


In reply to Re: Storing multiple blocks of text in the __DATA__ section by graff
in thread Storing multiple blocks of text in the __DATA__ section by blindluke

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.