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

Hello Perl Monks !!

I need a Perl/Tk module which works with different versions of perl. We use Perl/Tk to create many scripts in our organisation. But the problem that we found lately was that we have different perl versions at different site locations.

My observations so far:
1) Tried invoking perl v5.10.1 to use Perl/Tk module that used to work fine with perl v5.8.8. There was a symbol lookup error pointed. After checking the online stuff for similar errors, I learnt that I will need to change the perl module.

2) Installed Perl/Tk for perl v5.10.1. However, I landed up on similar error when tried using this newly downloaded Perl/Tk module with per v5.22.1. Also, I found that this newly downloaded Perl/Tk module for perl v5.10.1 is not working with perl v5.8.8

3) Installed Perl/Tk for perl v5.22.1. This time I landed up in issues when I used this newly dowloaded Perl/Tk module with perl v5.10.1 or perl v5.8.8. The error said somewhat like this "Can't load Tk.pm" which again appeared as version dependency of Perl/Tk as it worked well with perl version for which it was downloaded.

From above observations, one would assume that Perl/Tk module has a huge dependency on Perl versions. Everytime you upgrade your perl version, you need to also download a new compatible Perl/Tk module.

The support I seek here is to answer below questions:

Q-1) Is there any way that I can get a single Perl/Tk module which works for different Perl versions (or at least perl versions higher or same as perl v5.8.8)?

Q-2) If the answer to above question is "Not Possible!". Then is it really wise to use Perl/Tk module in the projects? I assume here that there will be many other users who might have faced this problem. But to my surprise I could not find any reasonable help online. Requesting all perlmonks to throw some light here.

Info that might be needed to refer:
=> OS used: Redhat Enterprise Linux Client (Release 6.7)
=> calling Tk module using "use Tk". The errors mentioned above are shown at this line.
=> Testing for a given Perl/Tk module with different perl version was done on different machines that has different perl versions installed
=> ______ - Let me know if any further info is needed.


Thanks a lot for your support !!

Replies are listed 'Best First'.
Re: Perl/Tk Version Dependency Issue
by choroba (Cardinal) on May 24, 2016 at 07:46 UTC
    It's not possible to use the same Tk for different Perl versions. It's possible, though, to have a separate Tk module for each Perl version, even on the same computer - yes, you can have more than one Perl version installed. See perlbrew, or local::lib. The trick is that each Perl knows where to search for its modules.
    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
      Hi Choroba,
      Thanks for your response !!

      Are you sure about this? Usually we may not expect that much of version dependency for any other perl module. Right?

      Even though my observations are same as what you have mentioned, I had difficulty in convincing my manager that Tk perl module is acutually entirely version dependent.

      But in case this is a bitter fact about which you are sure as well, I worry I may have to shift all my perl scripts away from Tk as we cannot have a sustainable script production this way due to high maintenance needs on each and every user's system.

      Looking forward to your reply on this.
        Any module that needs to compile XS code depends on Perl version (and C compiler version and flags). I doubt you can find any GUI module that doesn't depend on them.

        On the other hand, this doesn't mean high maintenance needs. Just ship your application together with the right Perl version, and you'll only have to manage single build of each module.

        Another option is to distribute the sources and dependencies and let the end users compile the modules themselves (by prepared scripts, of course).

        ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re: Perl/Tk Version Dependency Issue
by Corion (Patriarch) on May 24, 2016 at 07:03 UTC

    Where do you "download Perl/Tk module for Perl v5.xx.yy"? If you use a package manager to download prebuilt packages, these are tightly coupled to the Perl major version xx. You cannot mix modules from one Perl major version xx with another Perl binary.

    I recommend either building Tk with your Perl binary yourself or learning how to use your package manager and to install the appropriate Perl binary package and the appropriate Tk package.

      Hi Corion,
      Thanks for your reply on my query.

      Please excuse my beginner level knowledge on perl. I am not sure about information you have asked me so I am describing how I got the Tk module for a particular perl version.

      How I got Tk Perl Module?
      I have got the Tk module with help of IT team in my organization and I am not sure how exactly they have downloaded and installed Tk Module. But each time, my request was given to IT team was in this way -> "To install Tk module for a particular Perl v5.xx.1 version".

      Due to my very limited knowledge in managing modules in perl, I have difficulty understanding how to build Tk for a particular perl binary. But even if I somehow build Tk manually, will that ensure that it works for all perl versions? I assume here that you meant "perl version" by saying "perl binary".

      Looking forward to your reply on this.

        Perl binaries are even more specific than just Perl versions, but for the current discussion, Perl binary and Perl version can be used synonymously.

        There is no way that a single build of a module will work with all Perl versions. You need to build the module for each Perl version separately and install it separately. If you don't know how to instruct your IT team to solve this problem, we cannot help you because we don't know how your IT team receives its instructions.