Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Data::Dumper and eval

by broquaint (Abbot)
on Sep 25, 2003 at 09:18 UTC ( [id://294103]=note: print w/replies, xml ) Need Help??


in reply to Data::Dumper and eval

As perlmonkey has noted this problem is due to $VAR1 being undeclared. A remedy to this is to turn on $Data::Dumper::Terse which will do away with the $VAR1 e.g
use Data::Dumper; local $Data::Dumper::Terse = 1; my $hashref = { aaa => 1, bbb => 2, ccc => 3, }; print "hashref : " . Dumper($hashref); my $evalled = eval(Dumper($hashref)); print "evalled : " . Dumper($evalled); __output__ hashref : { 'ccc' => 3, 'bbb' => 2, 'aaa' => 1 } evalled : { 'ccc' => 3, 'bbb' => 2, 'aaa' => 1 }
Although you'll want to be careful you're not dumping a self-referential data structure
use Data::Dumper; local $Data::Dumper::Terse = 1; my $x; $x = \$x; __output__ \$VAR1
See. the Data::Dumper docs for more info.
HTH

_________
broquaint

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2024-04-24 11:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found