Hi, I've got a pretty complicated hash structure that I want to save to disk for reloading later. The structure has PDL's in it. After saving I looked at the file and it seems like the data dumper has not created a correct string. Being new to Perl, I can't interpret the code created by the dumper. But I know that one of the fields should contain a 20x10 PDL, and in the string, it is relatively short. Here is the section of the output that was created by Data::Dumper and saved to a file:
$VAR1 = { 'totGrain' => 5, 'grain' => [ { 'vList' => [ bless( do{\(my $o = 143207480)}, + 'PDL' ), bless( do{\(my $o = 143300056)}, + 'PDL' ), . . . bless( do{\(my $o = 135713008)}, + 'PDL' ) ], 'gList' => bless( do{\(my $o = 143207224)}, ' +PDL' ), 'area' => 28, 'origin' => bless( do{\(my $o = 143321728)}, +'PDL' ), 'shape' => bless( do{\(my $o = 135712552)}, ' +PDL' ), 'mList' => bless( do{\(my $o = 143299624)}, ' +PDL' ), 'centre' => bless( do{\(my $o = 143319144)}, +'PDL' ) }, . . . ], 'time' => 26, 'N' => 10, 'x' => bless( do{\(my $o = 143273584)}, 'PDL' ), 'totGrainActual' => 5, 'NGrain' => bless( do{\(my $o = 143299000)}, 'PDL' ), 'grainMean' => 40, 'M' => 20, 'sumArea2' => 8248, 'grainSigmaByMean' => '0.17606816861659', 'sumArea' => 200, 'grainSigma' => '7.0427267446636', 'name' => 'Voronoi_20x10_5_0.2', . . .
The $VAR1->{x} field and $VAR1->{o} fields should both be 20x10 PDL's, and they're somehow saved as a very short section of code. Previously, when I tried to recreate the structure in memory, I got a segmentation fault error. And after some more experimenting, I'm now getting:
Fatal error: argument is probably not a piddle, or magic no overwritte +n. You're in trouble, guv: 143374912 143324128 135000880
Any suggestions on how I can save this large structure to disk and get it back? The saved file is coming out 3MB in size. I would actually prefer a more compact and faster to write & read format. So if someone knows a better way to do it, please help. Thx

In reply to Difficulty saving PDL's to disk with Data::dumper by Chah

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.