I have now tested one example in the web address I gave in my last reply and all was fine.
I then tried to alter this so that the hash was defined as
$megalith{name} = 'Stonehenge';
and so on.

I found that I had to alter the freeze to
my $storedValues = freeze( \%megalith );
However, I then got the error
Reference found where even-sized list expected at 37
this line was the thaw line that I had put as
%megalith = thaw( $storedValues );
I have tried various things but so far failed to find an answer
can anyone explain how to correct this?
the full code is below

use strict "vars";
use Storable qw( freeze thaw );
### Create some values in a hash
my %megalith;
$megalith{name} = 'Stonehenge';
$megalith{mapref} = 'SU 123 400';
$megalith{location} = 'Wiltshire';
### Print them out
print "Initial Values: megalith = $megalith{name}\n" .
" mapref = $megalith{mapref}\n" .
" location = $megalith{location}\n\n";
### Store the values to a string
my $storedValues = freeze( \%megalith );
### Reset the variables to rubbish values
$megalith{name} = 'Flibble Flabble';
$megalith{mapref} = 'XX 000 000';
$megalith{location} = 'Saturn';
### Print out the rubbish values
print "Rubbish Values: megalith = $megalith{name}\n" .
" mapref = $megalith{mapref}\n" .
" location = $megalith{location}\n\n";
### Retrieve the values from the string
%megalith = thaw( $storedValues );
### Display the re-loaded values
print "Re-loaded Values: megalith = $megalith{name}\n" .
" mapref = $megalith{mapref}\n" .
" location = $megalith{location}\n\n";
exit;

In reply to Re^2: How to use packed binary data by merrymonk
in thread How to use packed binary data by merrymonk

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.