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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.