Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^4: Storing multiple blocks of text in the __DATA__ section

by blindluke (Hermit)
on Jan 03, 2015 at 13:53 UTC ( [id://1112056]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Storing multiple blocks of text in the __DATA__ section
in thread Storing multiple blocks of text in the __DATA__ section

Although, as LanX already noticed, my descriptions can contain several paragraphs, thank you for suggesting paragraph mode. Your solution is both simple and elegant.

And the technique with encoding line breaks could indeed work. I would switch the two regexps, so there is no need to assign the capture value to $key, and I would use the \\ linebreak symbol, as it is already associated with manual linebreak (in LaTeX).

#!/usr/bin/perl use strict; use warnings; my %desc; { local $/ = ""; while (<DATA>) { s/\\\\/\n/; s/^(.*)\n//; $desc{$1} = $_; } } print "{$_} => \n$desc{$_}" for (keys %desc); __DATA__ house_west You are standing in an open field west of a white house, with a boarded front door. \\ There is a small mailbox here. house_south You are facing the south side of a white house. There is no door here, and all the windows are boarded. house_behind You are behind the white house. A path leads into the forest to the east. \\ In one corner of the house there is a small window which is slightly a +jar.

Again, thank you for your suggestion and the provided examples.

- Luke

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1112056]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2025-12-14 13:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (94 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.