I want to define a hash reference like this:

my $h={
        a => 'aaaaaaaaa',
        b => 'aa &&\
                bbb',
};

(Note the string containing escaped newlines.)

Now, the point is that I have the block
        a => 'aaaaaaaaa',
        b => 'aa &&\
                bbb',
in a text file. It would be nice to be able to just slurp the file as-is
to define $h.

Is there any way to do this? The best workaround I can think of is to have a
modified file, with entries separated by empty lines:
        a => 'aaaaaaaaa',

        b => 'aa &&\
                bbb',

I could then slurp the file as a single string, split the string on
/\n\n/, etc., because I know the hash values will not contain empty
lines. But this leaves an uncomfortable feeling, since the original file
contents are already as we would write them in the main program...

Any idea?
--
Jorge Almeida

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to