| 1 | package Bio::Root::Version; | ||||||||||||||||||||||||||||
| 2 | 1 | $Bio::Root::Version::VERSION = '1.7.8'; | |||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | Bio::Root::Version - don't use, get version from each module | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | package Bio::Tools::NiftyFeature; | ||||||||||||||||||||||||||||
| 12 | require Bio::Root::RootI; | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # later, in client code: | ||||||||||||||||||||||||||||
| 15 | package main; | ||||||||||||||||||||||||||||
| 16 | use Bio::Tools::NiftyFeature 3.14; | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | ## alternative usage: NiftyFeature defines own $VERSION: | ||||||||||||||||||||||||||||
| 19 | package Bio::Tools::NiftyFeature; | ||||||||||||||||||||||||||||
| 20 | my $VERSION = 9.8; | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # later in client code: | ||||||||||||||||||||||||||||
| 23 | package main; | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | # ensure we're using an up-to-date BioPerl distribution | ||||||||||||||||||||||||||||
| 26 | use Bio::Perl 3.14; | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | # NiftyFeature has its own versioning scheme: | ||||||||||||||||||||||||||||
| 29 | use Bio::Tools::NiftyFeature 9.8; | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | This module provides a mechanism by which all other BioPerl modules | ||||||||||||||||||||||||||||
| 34 | can share the same $VERSION, without manually synchronizing each file. | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | Bio::Root::RootI itself uses this module, so any module that directly | ||||||||||||||||||||||||||||
| 37 | (or indirectly) uses Bio::Root::RootI will get a global $VERSION | ||||||||||||||||||||||||||||
| 38 | variable set if it's not already. | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | =head1 AUTHOR Aaron Mackey | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =cut | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: not called CC=4 SCAR=25.8
| |||||||||||||||||||||||||||||
| 45 | # try to handle multiple levels of inheritance: | ||||||||||||||||||||||||||||
| 46 | 0 | my $i = 0; | |||||||||||||||||||||||||||
| 47 | 0 | my $pkg = caller($i); | |||||||||||||||||||||||||||
| 48 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | while ($pkg) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | if ( $pkg =~ m/^Bio::/o | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pkg =~ /^Bio::/o and not defined ${$pkg . '::VERSION';}
MC/DC0%0/2
$pkg =~ /^Bio::/o and not defined ${$pkg . '::VERSION';}
$pkg =~ /^Bio::/o
not defined ${$pkg . '::VERSION';}
Truth table0%0/3
A and not(B)
A= $pkg =~ /^Bio::/oB= not defined ${$pkg . '::VERSION';}
| |||||||||||||||||||||||||||||
| 51 | 0 | and not defined ${$pkg . "::VERSION"} | |||||||||||||||||||||||||||
| 52 | ) { | ||||||||||||||||||||||||||||
| 53 | 0 | ${$pkg . "::VERSION"} = $Bio::Root::Version::VERSION; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | 0 | $pkg = caller(++$i); | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 1 | 1; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | __END__ | ||||||||||||||||||||||||||||