Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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" }


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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1111996]
[jedikaiti]: If I had a flying home, I'd be pretty psyched. How cool would that be?
[jedikaiti]: The big question is, does it have autopilot?
[shmem]: good autonomous flyer doesn't need a pilot.
[karlgoethebier]: The One And Only Flying Home

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2018-02-21 17:39 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (285 votes). Check out past polls.