Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

force using the version of a module

0 views
Skip to first unread message

Jeff Peng

unread,
Dec 26, 2009, 11:02:24 AM12/26/09
to begi...@perl.org
Hello,

The latest version of LWP::UserAgent (v5.834) has a method of
"local_address", which is needed by my software.

The lower version of this module (for example, v5.824) doesn't have that
method.

So how to force to use the latest version of LWP::UserAgent in the perl
script?

Thanks.
Merry Holidays!

Jeff.
____________________________________________________________
Love Spell
Click here to light up your life with a love spell!
http://thirdpartyoffers.netzero.net/TGL2241/c?cp=WY6rCVc8u7r0rhlGINenTgAAJ1F5p0Q5uwV0jfKaKm9vU9yEAAYAAAAAAAAAAAAAAAAAAADNAAAAAAAAAAAAAAAAAAAARwAAAAA=

Peter Scott

unread,
Dec 26, 2009, 11:56:00 PM12/26/09
to begi...@perl.org
On Sun, 27 Dec 2009 00:02:24 +0800, Jeff Peng wrote:
> The latest version of LWP::UserAgent (v5.834) has a method of
> "local_address", which is needed by my software.
>
> The lower version of this module (for example, v5.824) doesn't have that
> method.
>
> So how to force to use the latest version of LWP::UserAgent in the perl
> script?

% perldoc -f use
use Module VERSION LIST
use Module VERSION
[...]
If the VERSION argument is present between Module and LIST,
then the "use" will call the VERSION method in class Module
with the given version as an argument. The default VERSION
method, inherited from the UNIVERSAL class, croaks if the
given
version is larger than the value of the variable
$Module::VERSION.

--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/
http://www.informit.com/store/product.aspx?isbn=0137001274

Jeff Peng

unread,
Dec 27, 2009, 2:11:10 AM12/27/09
to begi...@perl.org
Peter Scott :

>
> % perldoc -f use
> use Module VERSION LIST
> use Module VERSION
> [...]
> If the VERSION argument is present between Module and LIST,
> then the "use" will call the VERSION method in class Module
> with the given version as an argument. The default VERSION
> method, inherited from the UNIVERSAL class, croaks if the
> given
> version is larger than the value of the variable
> $Module::VERSION.
>


Thanks. That's right for me.

Regards,
Jeff.

C.DeRykus

unread,
Dec 26, 2009, 3:15:12 PM12/26/09
to begi...@perl.org
On Dec 26, 8:02 am, jeffp...@netzero.net (Jeff Peng) wrote:
> Hello,
>
> The latest version of LWP::UserAgent (v5.834) has a method of
> "local_address", which is needed by my software.
>
> The lower version of this module (for example, v5.824) doesn't have that
> method.
>
> So how to force to use the latest version of LWP::UserAgent in the perl
> script?
>

use LWP::UserAgent 5.834; # See perldoc -f use

I'm not sure if there's a simpler way if loading with 'require
rather than 'use'. Perhaps:

use constant LWP_MIN_VER => 5.834;
require LWP::UserAgent;
unless ( $LWP::UserAgent::VERSION >= LWP_MIN_VER ) {
die "LWP::UserAgent version ", LWP_MIN_VER, " required",
"--this is only version $LWP::UserAgent::VERSION\n";
}

--
Charles DeRykus

0 new messages