cormanaz has asked for the wisdom of the Perl Monks concerning the following question:

I have a storable file I created on another Windows system (using method nstore) that I am trying to retrieve on the Windows system I'm using. I am getting error: Cannot restore overloading on SCALAR(0x1ed598a2d40) (package JSON::XS::Boolean) (even after a "require JSON::XS::Boolean;") at C:/Strawberry/perl/lib/Storable.pm

The odd thing is that I can retrieve it just fine on the other system so it's apparently not a problem with the file. Versioning problem?

If so is there a workaround?

Replies are listed 'Best First'.
Re: Storable: Cannot restore overloading on SCALAR
by hv (Prior) on Jul 15, 2024 at 23:48 UTC

    Do both systems have JSON::XS installed, and if so what version does each have? From the manpage of JSON::XS::Boolean (which is part of the JSON::XS distribution):

    This module exists only to provide overload resolution for Storable and similar modules. It's only needed for compatibility with data serialised (by other modules such as Storable) that was decoded by JSON::XS versions before 3.0.

    Since 3.0, JSON::PP::Boolean has replaced it. Support for JSON::XS::Boolean will be removed in a future release.

Re: Storable: Cannot restore overloading on SCALAR
by dasgar (Priest) on Jul 15, 2024 at 21:14 UTC

    I see that Strawberry Perl versions 5.16.2.1 and 5.16.2.2 both come with Storable version 2.39. If you download either of those portable Strawberry Perl versions to your system (with Strawberry Perl 5.38.2), you should be able to test to see if it might be related to version issues (Perl and/or Storable).

Re: Storable: Cannot restore overloading on SCALAR
by syphilis (Archbishop) on Jul 16, 2024 at 09:00 UTC
    <UPDATE> On further fiddling about, I now don't think there's much in what I've written below that actually holds much water.
    I think it might be 5.38.2's insistence on loading Math::BigInt::Calc that's causing the problem with the one-liners I provided.
    If I use Math::Complex instead of Math::BigInt, everything works fine.
    I'll leave this post as is, in case there's something here that triggers something useful.
    </UPDATE>

    Your perl-5.16.2 will be a 32-bit build; I presume your 5.38.2 is a 64-bit build (though StrawberryPerl did also provide a 32-bit build of 5.38.2).
    I have both AP-5.16.2 and (64-bit) SP-5.38.2 on this Windows 11 box.

    Using 5.38.2:
    D:\pscrpt\storable>perl -MMath::BigInt -MStorable -Mwarnings -le "$mbi + = Math::BigInt->new(12345); Storable::nstore(\$mbi, 'file.s'); $ret += Storable::retrieve('file.s'); print $$ret; print ref($$ret);" 12345 Math::BigInt
    Then, in another shell, using 5.16.2:
    D:\pscrpt\storable>perl -MMath::BigInt::Calc -MMath::BigInt -MStorable + -Mwarnings -le "$ret = Storable::retrieve('file.s'); print $$ret; pr +int ref($$ret);" Cannot restore overloading on ARRAY(0x23df904) (package Math::BigInt:: +Calc) (even after a "require Math::BigInt::Calc;") at C:/_32/ap1600/l +ib/Storable.pm line 380, at -e line 1.
    However, reading the OP, it seems that it's the other way around ... the file is being created by 5.16.2 and read by 5.38.2.
    And that works fine for me.
    Using 5.16.2
    D:\pscrpt\storable>del file.s D:\pscrpt\storable>perl -MMath::BigInt -MStorable -Mwarnings -le "$mbi + = Math::BigInt->new(12345); Storable::nstore(\$mbi, 'file.s'); $ret += Storable::retrieve('file.s'); print $$ret; print ref($$ret);" 12345 Math::BigInt
    Using 5.38.2:
    D:\pscrpt\storable>perl -MMath::BigInt -MStorable -Mwarnings -le "$ret + = Storable::retrieve('file.s'); print $$ret; print ref($$ret);" 12345 Math::BigInt
    I tried using store instead of nstore, but then both of those examples fail to retrieve(), reporting:
    Byte order is not compatible at .... , at -e line 1.
    In my case, I think it's the problem of a 32-bit architecture not handling 64-bit stuff.
    But if you're doing it the other way about, then I don't know. (My second example seems to confirm my belief that the 64-bit architecture will handle 32-bit stuff.)

    Cheers,
    Rob