| 1 | 5 | ▶ | use 5.006; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | |||||||||||||||
| 5 | package Gentoo::PerlMod::Version::Env; | ||||||||||||||
| 6 | |||||||||||||||
| 7 | 5 | our $VERSION = '0.8.0'; | |||||||||||||
| 8 | |||||||||||||||
| 9 | # ABSTRACT: Get/parse settings from %ENV | ||||||||||||||
| 10 | |||||||||||||||
| 11 | 5 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |||||||||||||
| 12 | |||||||||||||||
| 13 | 5 | my $state; | |||||||||||||
| 14 | 5 | my $env_key = 'GENTOO_PERLMOD_VERSION_OPTS'; | |||||||||||||
| 15 | |||||||||||||||
| 16 | |||||||||||||||
| 17 | |||||||||||||||
| 18 | |||||||||||||||
| 19 | |||||||||||||||
| 20 | |||||||||||||||
| 21 | |||||||||||||||
| 22 | sub opts { | ||||||||||||||
| 23 | 92 | ▶ | return $state if defined $state; | ||||||||||||
|
Subroutine
opts: called CC=6 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||
| 24 | 4 | $state = {}; | |||||||||||||
| 25 | 4 | ▶ | return $state if not defined $ENV{$env_key}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 26 | 1 | my (@tokes) = split /\s+/msx, $ENV{$env_key}; | |||||||||||||
| 27 | 1 | for my $token (@tokes) { | |||||||||||||
| 28 | 6 | ▶ | if ( $token =~ /\A([^=]+)=(.+)\z/msx ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 29 | 3 | $state->{"$1"} = "$2"; | |||||||||||||
| 30 | } | ||||||||||||||
| 31 | elsif ( $token =~ /\A-(.+)\z/msx ) { | ||||||||||||||
| 32 | 1 | delete $state->{"$1"}; | |||||||||||||
| 33 | } | ||||||||||||||
| 34 | else { | ||||||||||||||
| 35 | 2 | $state->{$token} = 1; | |||||||||||||
| 36 | } | ||||||||||||||
| 37 | } | ||||||||||||||
| 38 | 1 | return $state; | |||||||||||||
| 39 | } | ||||||||||||||
| 40 | |||||||||||||||
| 41 | |||||||||||||||
| 42 | |||||||||||||||
| 43 | |||||||||||||||
| 44 | |||||||||||||||
| 45 | |||||||||||||||
| 46 | |||||||||||||||
| 47 | |||||||||||||||
| 48 | |||||||||||||||
| 49 | |||||||||||||||
| 50 | |||||||||||||||
| 51 | sub hasopt { | ||||||||||||||
| 52 | 89 | ▶ | my ($opt) = @_; | ||||||||||||
|
Subroutine
hasopt: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 53 | 89 | return exists opts()->{$opt}; | |||||||||||||
| 54 | } | ||||||||||||||
| 55 | |||||||||||||||
| 56 | |||||||||||||||
| 57 | |||||||||||||||
| 58 | |||||||||||||||
| 59 | |||||||||||||||
| 60 | |||||||||||||||
| 61 | |||||||||||||||
| 62 | |||||||||||||||
| 63 | |||||||||||||||
| 64 | |||||||||||||||
| 65 | |||||||||||||||
| 66 | sub getopt { | ||||||||||||||
| 67 | 3 | ▶ | my ($opt) = @_; | ||||||||||||
|
Subroutine
getopt: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 68 | 3 | return opts()->{$opt}; | |||||||||||||
| 69 | } | ||||||||||||||
| 70 | |||||||||||||||
| 71 | 5 | 1; | |||||||||||||
| 72 | |||||||||||||||
| 73 | __END__ | ||||||||||||||