in reply to Why not include version.pm

RHEL has for quite some time stripped down core (version has been in core since v5.9.0), deeming the default install is a basic, non devel version. A few years ago, they removed CPAN and just as bad, ExtUtils::MakeMaker.

Can you show how you're using the module in order to perhaps write around it?

Replies are listed 'Best First'.
Re^2: Why not include version.pm
by Wiggins (Hermit) on Mar 28, 2016 at 12:15 UTC
    In the 'installer' Perl script, very early on, I check for the installed version of Perl. I need to trap this result in the application and explain to the person who is doing the install what the problem is, even if they don't know Perl.

    I don't remember where I found this but it tells me if the installed Perl is 5.12 or higher.

    use version; ... sub checkPerlVer { my $minVer = shift; # eg '5.12' my $installVer = `perl -v|grep -E '(v[1-9.]+)'`; if ($installVer =~ /\((v[\d+.]+)\)/){ #print "match $1\n"; my $reVer = $1; my $iver= version->parse($reVer); my $mver= version->parse($minVer); printf "Minimum Perl=$mver Installed Perl=$iver \n"; if ($mver <= $iver) { print "OK \n"; return 1; #OK }else{ print "NOPE\n"; return 0; #NOT OK } }else{ print "No version found: <$installVer>\n"; return 0; } }

    It is always better to have seen your target for yourself, rather than depend upon someone else's description.

      Ugh. This might return you the version of a different Perl executable than the one your script is run with.

      Why not use the $] variable, as documented in perlvar?

      print "Running under Perl $]\n";

      You will need to change your version check from '5.12' to '5.012' though, because that's what $] will contain.

        Thanks, followed your advice, a few less lines needed and probably more correct.

        It is always better to have seen your target for yourself, rather than depend upon someone else's description.