in reply to Data::Dumper in a nutshell?

Another use of Data::Dumper is persistent storage. If you want to reuse your variable a few days later in another program, you apply Data::Dumper to the variable, and you print the result into a file, or you store it into a database.

Then, in the next program, a few days later, you just do the file (or you eval the result of the database query), and your second program can use the value computed by the first program.

There are other modules to get persistency: Storable, Freezethaw, but their output is not human-readable.

Replies are listed 'Best First'.
Re: Re: Data::Dumper in a nutshell?
by Ryszard (Priest) on Feb 08, 2002 at 06:53 UTC
    For persistant storge, when a database is too much i use Storable.pm. Its such a funky bit of gear.
Security Issue with Data::Dumper as a persistence mechanism
by gellyfish (Monsignor) on Feb 08, 2002 at 16:32 UTC

    you just do the file (or you eval the result of the database query), and your second program can use the value computed by the first program.

    ... or discover that some black hat has replaced your file with one containing system('rm -rf /')

    Data::Dumper is not a good method of doing persistence, because of the need to evaluate the stored file as actual Perl code using do or eval your code is only as secure as your file storage.

    If you must have a Human Readable persistent storage then you probaby want to look at Data::DumpXML or Data::Denter

    with the former you might want to consider my talk from last years yapc::Europe about a security implication of deserializing Perl objects into your code.

    /J\