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

Object is to be passed between programs: Facing an issue while passing object as an input parameter to different perl versions from perl5.6.pl to perl5.24.pl. Provided below the code which has the problem. Using windows platform, how to solve this issue.

The reason to transfered the object from 5.6 to 5.24 is to invoke the web service which supports TLS 1.2 and also the output(live object) needs to be transferred from 5.24 to 5.6.

In the current program same object is used for input and output module.

Object flow : perl5.6 -> perl 5.24 -> web service written as perl module.

SharedBetweenPerls.pm:-

package SharedBetweenPerls; use warnings; use strict; use Exporter; our @ISA = 'Exporter'; our @EXPORT_OK = qw(getVal); sub new { my $self = { roleId => undef, username => undef, }; bless $self, 'SharedBetweenPerls'; return $self; } sub getVal{ my ($self) = @_; return $self->{'roleId'}; } 1;
v5.24.pl:- use warnings; use strict; use v5.24; use lib '.'; my ($self) = @_; print $self->{'roleId'};
v5.6.pl:- use warnings; use strict; use lib '.'; use SharedBetweenPerls; my $obj = new SharedBetweenPerls(); $obj->{'roleId'} = '10000'; $obj->{'username'} = 'test123'; my $roleId = $obj->getVal(); print "Value : $roleId \n"; my $from_5.24 = qx(path-to-perl-5.24 program_for_5.24.pl "$obj"); print "Return from function: $from_5.24"; **#Not Working**

Replies are listed 'Best First'.
Re: Object is to be passed between different version of scripts
by 1nickt (Canon) on Apr 10, 2020 at 17:53 UTC

    Hi,

    Perl programs can't return Perl objects. You'll need to serialize your object and then deserialize it in the other program.

    See, e.g., Storable, Sereal, YAML, JSON, CHI ...

    Hope this helps!


    The way forward always starts with a minimal test.
Re: Object is to be passed between different version of scripts
by clueless newbie (Curate) on Apr 11, 2020 at 02:22 UTC

    Is it necessary to pass the object between two different version of Perl? Or is it sufficient to perform (on the 5.24 side) handwaving that (on the 5.6 side) creates the object and executes methods on the object?

    If the latter then perhaps Jörn Reder's Event::RPC might offer some hope? The module originate in 2006 so it might be 5.6 compatible.

Re: Object is to be passed between different version of scripts
by jcb (Parson) on Apr 10, 2020 at 23:25 UTC

    I see an XY problem here. You might be able to get perl 5.6 to speak TLS1.2 by upgrading Net::SSLeay with a new version linked against a current OpenSSL. That would certainly be easier than trying to mix interpreter versions.

      Just upgrading Net::SSLeay is enough or code change required? Is there any procedure to upgrade Net::SSLeay? detail explaination required to proceed futher.

        You say you are using Perl 5.6, Net::SSLeay requires v5.8.1 as of v1.86_05, but supports TLS v1.2 as of release 1.59. Without knowing why you are stuck with a 20 year old perl calling a much more modern perl it's hard to understand why you simply just don't do everything with the modern version.

        Procedure to upgrade Net::SSLeay:

        1. Find versions of Net::SSLeay and OpenSSL that support perl-5.6 and TLS1.2 and each other. Use the latest version of OpenSSL that you can.
        2. Install upgraded OpenSSL where the build procedure for Net::SSLeay can find it.
        3. Unpack a new Net::SSLeay and run perl Makefile.PL && make && make test. If tests fail, try another nearby version of Net::SSLeay until you find one for which the tests pass. After your new Net::SSLeay has passed its tests, use make install to install it.
        4. Perl programs should now be able to use TLS1.2.

        Then get a migration path for moving the entire program to a modern perl interpreter planned, because there is probably no combination of Net::SSLeay and OpenSSL that provides TLS1.3 support in a perl-5.6 installation.