Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Storing multiple blocks of text in the __DATA__ section

by RMGir (Prior)
on Jan 02, 2015 at 13:43 UTC ( #1111996=note: print w/replies, xml ) Need Help??


in reply to Storing multiple blocks of text in the __DATA__ section

This is very low-tech, and isn't quite what you're looking for, but it would let you concentrate all the config bits in __DATA__:
#!/bin/env perl use strict; use warnings; use Data::Dumper; my $data = join "",<DATA>; my $config = eval "{$data}" or die "eval failed, $@"; print Dumper($config); __DATA__ foo => "This is foo's data" , bar => qq{this is bar's data it includes a newline and other stuff} , baz => { bazfoo => "baz is more complex" , bazbar => "it contains a sub-hash" }

Mike

Replies are listed 'Best First'.
Re^2: Storing multiple blocks of text in the __DATA__ section
by blindluke (Hermit) on Jan 02, 2015 at 14:40 UTC

    Thanks for the reply and your time, but this solution just moves the variable assignments from within the code to the DATA section at the end of it.

    What would be the use of such a thing? My point was never moving the text to a specific place in my code, and placing it in __DATA__ was never an end unto itself.

    The point is making the code easier to read by putting the text descriptions as far away from the code syntax as possible. That way, someone can open the file, ignore all the Perl code, and edit the descriptions as any text document.

    - Luke

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1111996]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2018-06-19 21:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (115 votes). Check out past polls.

    Notices?