Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Data::Dumper in a nutshell?

by Sweeper (Pilgrim)
on Feb 08, 2002 at 06:41 UTC ( [id://144051]=note: print w/replies, xml ) Need Help??


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\

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://144051]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2024-04-19 09:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found