Stas Bekman wrote:
Rafael Garcia-Suarez wrote:

Stas Bekman wrote in perl.perl5.porters :

I'm facing a problem where loading a module in order to test its
version, is unapplicable. When a certain module/version is required
it's ok to load the module and die if the version is not
satisfactory.



You can use ExtUtils::MM_Unix->parse_version($pmfile).


Thanks Rafael, but you end up with an ugly code like:

                for my $path (@INC) {
                    my $pmfile = "$path/$file";
                    next unless -e $pmfile;
                    ExtUtils::MM_Unix->parse_version($pmfile);
                }

It sounds like an opportunity for a core API to encapsulate this functionality. e.g. VERSION_NO_LOAD?

Unfortunately ExtUtils::MM_Unix->parse_version is unusable, because it doesn't work under -T :( That leaves me no choice but to duplicate loads of code :(


#!/usr/bin/perl-blead-ithread -wlT
require ExtUtils::MM_Unix;
my $file = "CGI.pm";
for my $path (@INC) {
    my $pmfile = "$path/$file";
    next unless -e $pmfile;
    print ExtUtils::MM_Unix->parse_version($pmfile);
    last;
}

gives:

Insecure dependency in eval while running with -T switch at /usr/lib/perl5/5.8.3/ExtUtils/MM_Unix.pm line 3123, <FH> line 22.

Here is the fix against blead perl:

--- lib/ExtUtils/MM_Unix.pm.orig        2004-03-23 12:06:37.153572807 -0800
+++ lib/ExtUtils/MM_Unix.pm     2004-03-23 17:27:25.849684620 -0800
@@ -3092,6 +3092,8 @@
        next if $inpod || /^\s*#/;
        chop;
        next unless /(?<!\\)([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
+        # untaint
+        { local($1, $2); ($_ = $_) = /(.*)/; }
        my $eval = qq{
            package ExtUtils::MakeMaker::_version;
            no strict;

most likely it won't apply because of the bloody tabs, so I've attached it as well for your convenience.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com
--- lib/ExtUtils/MM_Unix.pm.orig	2004-03-23 12:06:37.153572807 -0800
+++ lib/ExtUtils/MM_Unix.pm	2004-03-23 17:27:25.849684620 -0800
@@ -3092,6 +3092,8 @@
 	next if $inpod || /^\s*#/;
 	chop;
 	next unless /(?<!\\)([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
+        # untaint
+        { local($1, $2); ($_ = $_) = /(.*)/; }
 	my $eval = qq{
 	    package ExtUtils::MakeMaker::_version;
 	    no strict;

Reply via email to