On the other hand, I also borrowed the use of the $VERSION variable from the module world:
use version; my $VERSION = qv( '0.0.1' );Argh! Now I've to update the VERSION in two places! What's worst, this happens with modules as well, even if this kinda bothers me less because I'm not that module creator :)
Regarding scripts, I'm leaning towards eliminating the $VERSION variable, just because I seem to use it as a result of some sneaky form of cargo cult. Before I do this, anyway, I'd like to hear comments. Regarding modules, I understand the need for $VERSION, but then the double-VERSION problems strikes back.
How do you address this problem?
Flavio
perl -ple'$_=reverse' <<
I understand what you mean, it is difficult to manage the VERSION variable between multiple scripts and modules in the same distribution. Mainly because it feels like additional busy work. I do view it this way and it helps me focus on why I try to keep the version updated.
edit: this seems to work much better than my original idea:
our $VERSION;
my $version_pod = <<"=cut";
=pod
=head1 NAME
blah blah
=head1 VERSION
@{[
$VERSION = "0.23"
]}
=cut
update: any ideas how to get the @{[]} stuff out with =for comment?
here my original idea: i found a very easy way to keep pod version numbers up-to-date. don't know if that helps in your case, but here it is:
my $version_pod = <<'=cut';
=pod
=head1 NAME
blah blah...
=head1 VERSION
our $VERSION = "0.63";
=cut
our $VERSION = "0.63";
# ...
sub __test_version {
my $v = __PACKAGE__->VERSION;
return 1 if $version_pod =~ m/VERSION.*\Q$v/;
return;
}
testfile:
use Test::More tests => 2;
BEGIN { use_ok('My::Module') };
ok(My::Module->__test_version, "version ok");
as i do make test as often as possible, i never forget the version number...
still, it would be cool if you could do
our $VERSION = ($version_pod =~ m/^our \$VERSION = "(\d+(?:\.\d+)+)"/m) ? $1 : "0.01";but doesn't work with make tardist, for example
[Aristotle] has elaborated a cool hack [http://use.perl.org/~Aristotle/journal/30358|here on use.perl.org], I hope not to infring any copyright duplicating it here:
eval "package Some::Module; $_" for grep m/ = /, split /\n/, <<'=cut'; =head1 VERSION =for fooling makemaker =cut-feigned This document describes Some::Module, $VERSION = 0.1 =cutthat yields:
$ perldoc ./Some/Module.pm | grep VERSION
This document describes Some::Module, $VERSION = 0.1
$ perl -MSome::Module \
-le'print Some::Module->VERSION'
0.1
$ perl -MExtUtils::MakeMaker \
-le'print MM->parse_version(shift)' Some/Module.pm
0.1
Wow, the road to the Dark Side of the Perl is surely attractive!
Flavio
perl -ple'$_=reverse' <<
perlmonks.org content © perlmonks.org and frodo72, Herkum, tinita
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03