11.9. How do I determine the version of perl/Tk that I am running?

Version numbering has changed recently and determining the version of perl/Tk that you are running now depends on what version you are running:

Tk-b10++:
Tk-b10 (and higher) has changed to $Tk::VERSION rather than $Tk:Version to be consistent with other packages.

Tk-b9.01:
The version numbers as of Tk-b9.01 are stored in the following variables:

    Core Tk version : $Tk::version
    Tk patchLevel :   $Tk::patchLevel
    library :         $Tk::library
    perl/Tk Version : $Tk::Version 
At your shell prompt you could say something like the following to determine you perl/Tk Version:
    perl -e 'use Tk; print "$Tk::Version\n";'
The switch to Tk-b9.01 from previous versions included a large number of method name changes. Nick was kind enough to include a b9names script in the distribution that assists with the job of updating your older scripts. See the b9names script for a rather complete discussion of the name changes. Geoffroy Ville also posted a notice of some of the changes. Here is a brief (and very incomplete!) summary:

older                         Tk-b9.01++
packslaves                    pack('slaves')
packpropagate                 pack('propagate')
packForget                    pack('forget')
                              pack('info')

$w->delete if ($w);            $w->destroy if ($w);

Tk-b8(--):
A little script (Tk_module) can tell you and return the value:

    #!/usr/bin/perl
    use Tk;
    local(*Tk_m) = \$Tk::Tk_module;
    print "$Tk_m\n";
Or more succintly say something like the following (at your shell prompt):
    perl -e 'use Tk; print "$Tk::Tk_module\n";'
You can obtain the version of Tk in use with the following (at your shell prompt):
    perl -e 'use Tk; print "$Tk::tk_version\n";'
where this command returned "4.0" when the previous one (or Tk_module) returned "b8".

All Tk versions:
Don't forget that you can always determine your Perl version/patchlevel/etc. with:

    perl -v
(at the shell prompt - it's actually a little harder to get as much information from within a #!script.) As of perl 5.002 you can use perl -V to determine your perl Configuration.

Ozawa Sakuro <ozawa@prince.pe.u-tokyo.ac.jp> points out some ways to do it in a script:

  1. '$]' holds the version number.
  2. In Perl5, 'require NUMBER;' will complain if version is younger than NUMBER. (e.g. require 5.001;)
  3. Of course, newly imported (and incompatible) features in newer scripts will bailout before execution if parsed by an old interpreter.
Note that if you use English; then $PERL_VERSION holds the version number.

To determine your MakeMaker version number try something like this (5.002):

    perl -MExtUtils::MakeMaker -e 'print "$ExtUtils::MakeMaker::VERSION\n";'
or this (5.001m ok):
    perl -e 'use ExtUtils::MakeMaker; print "$ExtUtils::MakeMaker::VERSION\n";'
or even this (older perls and MakeMakers):
    perl -e 'use ExtUtils::MakeMaker; print "$ExtUtils::MakeMaker::Version\n";'
Please note that thoughout this FAQ document there are references to things like Tk-b10(++) or Tk-b10++ which roughly translated to use English; means something like "I think this will work with this version of Tk and (masybe) higher versions...". You might also see Tk-b8(--) which means something like "it worked with that old version and probably worked with prior versions and if you are stuck with an old Tk version you might have to do it this way...".

Previous | Return to table of contents | Next