bsb has asked for the wisdom of the Perl Monks concerning the following question:

The Perl output from Data::Dumper doesn't seem to maintain the modifiability of
$rw_var = \do{ my $funky = "thing"}

See the error at the end:

$ perl -MData::Dumper -de1 DB<1> $Data::Dumper::Purity=1; DB<2> $d = \do { my $a = 'blah blah' }; DB<3> x $d 0 SCALAR(0x830501c) -> 'blah blah' DB<4> s/b/B/g for $$d; DB<5> x $d 0 SCALAR(0x830501c) -> 'Blah Blah' DB<6> p Dumper $d $VAR1 = \'Blah Blah'; DB<7> x eval Dumper $d 0 SCALAR(0x839c84c) -> 'Blah Blah' DB<8> s/B/X/g for (${eval Dumper $d}); Modification of a read-only value attempted at (eval 11)[/usr/share/pe +rl/5.6.1/perl5db.pl:1521] line 2.
Brad

PS. I hit this modifying treemap code.
Are there other things like treemap around?
That is, code to do Structure Shy Traversal.

Replies are listed 'Best First'.
Re: Data::Dumper + \"constant" problems
by demerphq (Chancellor) on Oct 01, 2003 at 09:12 UTC

    This is a known problem. I actually wrote a fix for it one time, Ill see if I can dig it out and send it to Ilya. BFDump handles this better, but I dont recommend BFDump for use these days. Not until the new version is released.


    ---
    demerphq

      First they ignore you, then they laugh at you, then they fight you, then you win.
      -- Gandhi


      I thought that might be your answer :)

      Thanks.

        Actually I should have said that when I have time ill be looking at your link about structure shy traversal. It sounds interesting.

        Sorry I couldnt be more helpful with the ref to string bit. As I believe I've said before DD doesnt handle refs to scalars as well as it should. Fine for visual inspection, terrible for reuse.

        Actually iirc this one of the few things that Data::Dump does better than Data::Dumper (watch out though you can get Data::Dump to hang on certain types of circular data structure.)

        Also the more you prod me the faster ill get a new version of BFDump out the door. I appreciate the heads up and reminders. :-)


        ---
        demerphq

          First they ignore you, then they laugh at you, then they fight you, then you win.
          -- Gandhi