Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Storing multiple blocks of text in the __DATA__ section

by RMGir (Prior)
on Jan 02, 2015 at 13:43 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1111996]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-19 04:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found