While I have made use of Data::Dumper in the past to examine data structures, I've only used it as a trouble shooting tool, never a storage mechanism. Having run into reputer and noticing that it used this method of storing data between sessions, I thought I would give it a try.
I am attempting to read two of the files generated by reputer back in so I can explore this a bit. There are two HoAoH's in each file along with a single scalar at the end, of which I only want the second HoAoH(nested between first HoAoH and trailing scalar).
The problem: The eval you see in the code below works just fine, but the assignment within the if does not. What it does do is read in each internal data structure(I can see them in the Globals when debugging), keeps available the first one, but the second two go out of scope(it seems) just before I try the assignment. The first data structure remains available. I did read through the Data::Dumper perldoc, but may have mis-understood something. Got a notion I am missing something very basic here.
#!/usr/bin/perl use strict; use warnings; use diagnostics; use Data::Dumper; my ($now, $then,$now1,$then1,$now_data,$then_data); $now = "/var/www/framechat_files/reputer.now"; $then = "/var/www/framechat_files/reputer.then"; if (eval "require '$now'") { $now_data = $now1; # hash containing parsed usernodes xml } if (eval "require '$then'") { $then_data = $then1; # hash containing parsed usernodes xml } $Data::Dumper::Varname = "now"; print Dumper($now1); print "############################################################### +#####################\n"; $Data::Dumper::Varname = "then"; print Dumper($then1);
Output:
$now1 = undef; ###################################################################### +############## $then1 = undef;
Could someone give me a pointer at what I am missing here?
What makes the last two read in data structures seemingly go out of scope before I can assign them to my variables while the first remains available?
Thanks for taking the time...
...the majority is always wrong, and always the last to know about it...
Insanity: Doing the same thing over and over again and expecting different results...
A solution is nothing more than a clearly stated problem...otherwise, the problem is not a problem, it is a fact
In reply to (Solved) Basic Data::Dumper read back question by wjw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |