On Fri, Dec 20, 2013 at 10:38:38AM -0500, Yanick Champoux wrote: > [... you could ] adopt the new behavior if the module is called with > the new version 'use Finance::Bank::CUKP 1.23;'. If the module is > called with no version or an older version, you keep the old > behavior, but issue a deprecation warning [...]
Thanks for mentioning it - this part of "use Module Version" behaviour has been around a long time, but I had not noticed it. https://metacpan.org/pod/release/LBROCARD/perl5.005_04/pod/perlfunc.pod#use-Module-VERSION-LIST (links to docs for obsolete Perl and) says | 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. (Note that there is not a | comma after VERSION!) Corollary: if you override VERSION without knowing this, you can break minimum version checking. It turns out, modules I have around here don't define "sub VERSION", but some has the old? common? [1] idiom "use constant VERSION => ..." and this does make the version check ineffective. $ cat modules/Foo.pm package Foo; use strict; use warnings; use YAML 'Dump'; # our $VERSION = 4; #sub VERSION { # print Dump({ VERSION => \@_ }); # return 4; #} use constant VERSION => 4; sub import { print Dump({ import => \@_ }) } 1; $ perl -Imodules -e 'use Foo 6.00; print Foo->VERSION, "\n"' --- import: - Foo 4 Oops. -- Matthew [1] https://duckduckgo.com/html/?kf=b&q=%22use%20constant%20version%22 -- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE.