Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 749271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:24:56+00:00 2026-05-14T14:24:56+00:00

I want to insert a hash in the db using Storable::nfreeze but the data

  • 0

I want to insert a hash in the db using Storable::nfreeze but the data is not inserted properly.

My code is as follows:

%rec=();
$rec{'name'} = 'my name';
$rec{'address'} = 'my address';

my $order1 = new Order();
$order1->set_session(\%rec);
$self->createOrder($order1);

sub createOrder {
my $self  = $_[0];
my $order = $_[1];


# Retrieve the fields to insert into the database.
my $st = $dbh->prepare("insert into order (session,.......) values(?,........)");

my $session   = %{$order->get_session()};
$st->execute(&Storable::nfreeze(\%session),.....);
$st->finish();

}

sub getOrder
{
     ...

    my $session = &Storable::thaw( $ref->{'session'} );
    .....
}    

The thaw is working fine because I tested it withe some rows that have been inserted correctly, but when I try to get a row that was inserted using the createOrder subroutine, I get an error saying:

Storable binary image v36.65 more recent than I am (v2.7) at blib/lib/Storable.pm (autosplit into blib/lib/auto/Storable/thaw.al) line 415

The error comes from the line that have thaw. The nfreeze did not store the hash properly.

Can someone point me to what I’m doing wrong in the createOrder subroutine?

I know the module version have nothing to do with the problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:24:57+00:00Added an answer on May 14, 2026 at 2:24 pm

    Your problem is probably improper dereferencing here:

    my $session   = %{$order->get_session()};
    $st->execute(&Storable::nfreeze(\%session),.....);
    

    This should fix it:

    my $session   = $order->get_session();
    $st->execute(&Storable::nfreeze($session),.....);
    

    Since ->get_sessionreturns a hash reference, when you dereferenced it in scalar context it was turning into a string that contains statistics on the hash. The hash %session is the empty package variable %main::session which you would have caught if you were running with use strict; use warnings;.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to insert something into a STL list in C++, but I only
I want to insert multiple invisible watermarks into my JPEG pictures through C# code.
I want to insert char (A) in second index where code start with 's'
I'm using LinkedHashSet. I want to insert items at the 0th position, like: Set<String>
I want to insert some value from first and second foreach into database, but
I want to insert say 50,000 records into sql server database 2000 at a
I want to insert a new row into an Access database. I'm looking at
I want to insert a pair< string, vector<float> > into a map, first it
I have a vector that I want to insert into a set . This
As the subject says I want to insert an image into the 2nd column

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.