| 1 | package Heap::Simple; | ||
| 2 | 1 | ▶ | use Carp; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | # Switch selecting XS or pure perl | ||
| 6 | 1 | ▶ | use vars qw($VERSION @ISA @implementors); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | $VERSION = "0.13"; | ||
| 8 | |||
| 9 | unless (@ISA) { | ||
| 10 | @implementors = qw(Heap::Simple::XS(0.10) Heap::Simple::Perl(0.13)) | ||
| 11 | unless @implementors; | ||
| 12 | for my $i (@implementors) { | ||
| 13 | my $plugin = $i; | ||
| 14 | my $version = $plugin =~ s/\((.+)\)\z// ? $1 : undef; | ||
| 15 | my $p = "$plugin.pm"; | ||
| 16 | $p =~ s!::!/!g; | ||
| 17 | if (eval { require $p; 1 }) { | ||
| 18 | *new = $plugin->can("new") || | ||
| 19 | croak "Package '$plugin' does not support 'new'"; | ||
| 20 | if (defined $version) { | ||
| 21 | if (defined(my $v = $plugin->VERSION)) { | ||
| 22 | if ($v < $version) { | ||
| 23 | carp "Need '$plugin' version $version, found version $v"; | ||
| 24 | next; | ||
| 25 | } | ||
| 26 | } else { | ||
| 27 | croak "Could not determine the version of '$plugin'"; | ||
| 28 | } | ||
| 29 | } | ||
| 30 | @ISA = ($plugin); | ||
| 31 | last; | ||
| 32 | } | ||
| 33 | } | ||
| 34 | @ISA || croak "Can't locate ", join(" nor ", @implementors), " in \@INC. This probably means you didn't install any of them. (\@INC contains: @INC)"; | ||
| 35 | } | ||
| 36 | |||
| 37 | 1; | ||
| 38 | __END__ | ||