| 1 | 4 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | package LV; | ||||||||||
| 6 | |||||||||||
| 7 | 4 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||
| 8 | 4 | our $VERSION = '0.006'; | |||||||||
| 9 | |||||||||||
| 10 | 4 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=8.1
| |||||||||||
| 11 | 4 | *_subname = eval { require Sub::Name } | |||||||||
| 12 | ? \&Sub::Name::subname | ||||||||||
| 13 | 0 | ▶ | : sub { $_[1] } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 14 | 4 | ▶ | }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | |||||||||||
| 16 | 4 | ▶ | use Exporter (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 4 | our @ISA = qw( Exporter ); | |||||||||
| 18 | 4 | our @EXPORT = qw( lvalue ); | |||||||||
| 19 | 4 | our @EXPORT_OK = qw( get set ); | |||||||||
| 20 | |||||||||||
| 21 | 15 | ▶ | sub get (&;@) { my $caller = (caller(1))[3]; get => _subname("$caller~get", shift), @_ } | ||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 22 | 15 | ▶ | sub set (&;@) { my $caller = (caller(1))[3]; set => _subname("$caller~set", shift), @_ } | ||||||||
|
Subroutine
set: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 23 | |||||||||||
| 24 | { | ||||||||||
| 25 | 4 | my $i; | |||||||||
| 26 | |||||||||||
| 27 | sub implementation | ||||||||||
| 28 | 3 | ▶ | { | ||||||||
|
Subroutine
implementation: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 29 | 3 | return $i; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | sub _set_implementation | ||||||||||
| 33 | 4 | ▶ | { | ||||||||
|
Subroutine
_set_implementation: called CC=2 SCAR=8.4
| |||||||||||
| 34 | 4 | my $module = shift; | |||||||||
| 35 | 4 | ▶ | *lvalue = $module->can('lvalue') or do { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 0 | require Carp; | |||||||||
| 37 | 0 | Carp::croak("$module does not appear to be an LV backend"); | |||||||||
| 38 | }; | ||||||||||
| 39 | 4 | $i = $module; | |||||||||
| 40 | } | ||||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 4 | ▶ | if ( $ENV{PERL_LV_IMPLEMENTATION} ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | { | ||||||||||
| 45 | 3 | my $module = sprintf('LV::Backend::%s', $ENV{PERL_LV_IMPLEMENTATION}); | |||||||||
| 46 | 3 | ▶ | eval "require $module; 1" or do { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 0 | require Carp; | |||||||||
| 48 | 0 | Carp::croak("Could not load LV backend $module"); | |||||||||
| 49 | }; | ||||||||||
| 50 | 3 | _set_implementation($module); | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | else | ||||||||||
| 54 | { | ||||||||||
| 55 | 1 | my @implementations = qw( | |||||||||
| 56 | LV::Backend::Sentinel | ||||||||||
| 57 | LV::Backend::Magic | ||||||||||
| 58 | LV::Backend::Tie | ||||||||||
| 59 | ); | ||||||||||
| 60 | |||||||||||
| 61 | 1 | for my $module (@implementations) | |||||||||
| 62 | { | ||||||||||
| 63 | 1 | ▶ | if (eval "require $module; 1") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | { | ||||||||||
| 65 | 1 | _set_implementation($module); | |||||||||
| 66 | 1 | last; | |||||||||
| 67 | } | ||||||||||
| 68 | } | ||||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 4 | ▶ | unless (__PACKAGE__->can('lvalue')) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | { | ||||||||||
| 73 | 0 | require Carp; | |||||||||
| 74 | 0 | Carp::croak("No suitable backend found for lv"); | |||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 4 | 1; | |||||||||
| 78 | |||||||||||
| 79 | __END__ | ||||||||||