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

Ok, i use data dumper to put a lot of data into a text field in my database and this has been working well for several months now but then today it stopped working. I didn't change anything and no one else is sopposed to have access to my server...
It seems like it's not putting quotes around strings for some reason. anyways i have to problems now. 1 fixing it so it doesn't do this anymore and 2 fixing all the broken records that no longer eval (several thousand of them)
(A shortend version of what it's outputting)
$VAR1 = {building => { production => [0,75], current => Construction Y +ard }, heard => Had a Previous Acount , spells => {}, email => creato +rNOSPAM @ operamail.com , };

Replies are listed 'Best First'.
Re: Data Dumper not outputting valid perl?
by robartes (Priest) on Apr 28, 2003 at 06:19 UTC
    From the looks of it, you might have a problem with the unquoted email address in that variable. However, a quick test with Data::Dumper at my machine shows that a string containing @ is correctly quoted in Data::Dumper output.

    Could you post some more information - the error produced and the code that generates that Data::Dumper output would be helpful in providing more context for this.

    In the mean time, try setting Data::Dumper::Useqq to true and see if that changes anything. I got this from the docs, but I have no experience with that setting, so YMMV.

    Update: With so many barewords in the output, the email address might not be your only worry.

    CU
    Robartes-

Re: Data Dumper not outputting valid perl?
by demerphq (Chancellor) on Apr 28, 2003 at 10:43 UTC

    Having some experience with the innerds of Data::Dumper I think I can state catagorically that the standard module would never do that at all. So either someone has hacked it (and indication would be that if you turn on Useqq if the results are different) or somekind of post processing happening that you are not aware of. To be honest though I think that Data::Dumper being hacked is extremely unlikely. The standard version comes in a PP and XS implementation and I think a hacker would have to do a lot of work to break it in this way without breaking it totally. My guess is that something else has been modified or hacked, and more likely the former. If ti was the dumper id love for you to post the hacked version.


    ---
    demerphq

    <Elian> And I do take a kind of perverse pleasure in having an OO assembly language...
Re: Data Dumper not outputting valid perl?
by Juerd (Abbot) on Apr 28, 2003 at 06:18 UTC

    It seems like it's not putting quotes around strings for some reason. anyways i have two problems now.

    It's hard to imagine Data::Dumper did that.

    You might be able to write a parser for what you have now, but it would have to guess a lot.

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Re: Data Dumper not outputting valid perl?
by Anonymous Monk on Apr 28, 2003 at 10:16 UTC

    Can you write a test case?

    A simple script with a pre-initialized structure, to see if the problem can be reproduced.

Re: Data Dumper not outputting valid perl?
by thraxil (Prior) on Apr 28, 2003 at 15:06 UTC

    are you sure Data::Dumper is producing that broken code, or perhaps is it producing correct code and it's getting screwed up when you put it into the database. are you using placeholders for your DBI inserts or do you have some custom quoting routine which may somehow be deleting the quotes in the name of "security"?

    ie, does your SQL look like:

    INSERT INTO foo_table (stuff) values (?)

    or,

    INSERT INTO foo_table (stuff) values ($string)

    if it's the latter, i have a strong suspician that that is related to your problem.

    posting the code which generates that string and then inserts it into the database would help us diagnose things.

    anders pearson

Re: Data Dumper not outputting valid perl?
by LordWeber (Monk) on Apr 28, 2003 at 06:34 UTC
        problem solved... my bad... some idiot decided to change where it escapes ' 's to instead delete them...
          If the core Data::Dumper is doing that, your Perl installation got hosed up somehow. Are you sure you're getting the original version, and not some locally modified installation? I seriously doubt Perl would pass its own "make test" with that kind of output.

          -- Randal L. Schwartz, Perl hacker
          Be sure to read my standard disclaimer if this is a reply.