| 1 | package FindApp::Utils::Package::Object; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use v5.10; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use FindApp::Utils::Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use FindApp::Utils::Assert qw(:all); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use FindApp::Utils::Syntax qw(:all); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use List::Util qw(max); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 6 | use Scalar::Util qw( | |||||||||||||||||||||||||||||||||||||||||
| 12 | blessed | ||||||||||||||||||||||||||||||||||||||||||
| 13 | looks_like_number | ||||||||||||||||||||||||||||||||||||||||||
| 14 | reftype | ||||||||||||||||||||||||||||||||||||||||||
| 15 | 6 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | sub selfhere { | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 696 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
selfhere: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 696 | ▶ | my $here = shift || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 1
MC/DC100%1/1
shift() || 1
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 696 | ▶ | looks_like_number($here) || subcroak_N(2, "'$here' does not look like a number"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 696 | ▶ | $here = ($here <=> @$self) * @$self if abs($here) > @$self; # limit magnitude, keep sign | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 696 | return ($self, $here); | |||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 6 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | sub PACKAGE ( ;$ ) ; | ||||||||||||||||||||||||||||||||||||||||||
| 28 | sub UNPACKAGE ( _ ) ; | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 6 | ▶ | use Exporter "import"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 6 | our @EXPORT = <{,UN}PACKAGE>; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 6 | our @EXPORT_OK = @EXPORT; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 6 | our %EXPORT_TAGS = ( all => \@EXPORT_OK ); | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 6 | ▶ | use FindApp::Utils::Objects <op_{,not}equals>; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 6 | ▶ | use overload map { $_ => "op_$_" } <cmp eq ne>; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 6 | use overload reverse ( | |||||||||||||||||||||||||||||||||||||||||
| 39 | unbless => qw( "" ), | ||||||||||||||||||||||||||||||||||||||||||
| 40 | length => qw( 0+ ), | ||||||||||||||||||||||||||||||||||||||||||
| 41 | op_equals => qw( == ), | ||||||||||||||||||||||||||||||||||||||||||
| 42 | op_notequals => qw( != ), | ||||||||||||||||||||||||||||||||||||||||||
| 43 | op_spaceship => qw( <=> ), # now with 👽 wormholes! | ||||||||||||||||||||||||||||||||||||||||||
| 44 | op_plus => qw( + ), | ||||||||||||||||||||||||||||||||||||||||||
| 45 | op_minus => qw( - ), | ||||||||||||||||||||||||||||||||||||||||||
| 46 | op_neg => qw( neg ), | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 6 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | # Exported constructor via string, defaults to caller's package | ||||||||||||||||||||||||||||||||||||||||||
| 50 | # and imposes scalar context on its argument so you can pass | ||||||||||||||||||||||||||||||||||||||||||
| 51 | # it PACKAGE(caller) more easily. You can call it as &PACKAGE | ||||||||||||||||||||||||||||||||||||||||||
| 52 | # to circumvent the prototype so you can pass multiple bits | ||||||||||||||||||||||||||||||||||||||||||
| 53 | # to the constructor, as in | ||||||||||||||||||||||||||||||||||||||||||
| 54 | # &PACKAGE(map {ucfirst} <three blind mice>) | ||||||||||||||||||||||||||||||||||||||||||
| 55 | # To get a Three::Blind::Mice object back without being forced to type | ||||||||||||||||||||||||||||||||||||||||||
| 56 | # new FindApp::Utils::Package::Object map {ucfirst} <three blind mice> | ||||||||||||||||||||||||||||||||||||||||||
| 57 | sub PACKAGE(;$) { | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 535 | ▶ | __PACKAGE__ -> new(@_ ? @_ : scalar caller); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
PACKAGE: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | # And this one goes the other way, mostly for mapping. | ||||||||||||||||||||||||||||||||||||||||||
| 62 | # This is just the functional version of the method, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | # with a builtin default argument of $_ for convenience. | ||||||||||||||||||||||||||||||||||||||||||
| 64 | sub UNPACKAGE(_) { | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 509 | ▶ | my($package) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
UNPACKAGE: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 509 | my $unpackage = $package->unbless; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 509 | ▶ | if (defined wantarray) { return $unpackage } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | else { $_[0] = $unpackage } | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | # Constructor via string, defaults to caller's package. | ||||||||||||||||||||||||||||||||||||||||||
| 72 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 2549 | ▶ | my $invocant = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=20.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 2549 | ▶ | my $class = blessed($invocant) || $invocant; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
builtin::blessed($invocant) || $invocant
MC/DC0%0/2
builtin::blessed($invocant) || $invocant
builtin::blessed($invocant)
$invocant
Truth table66%2/3
A || B
A= builtin::blessed($invocant)B= $invocant
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 2549 | ▶ | return $invocant->new(join "::", @_) if @_ > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | #my $path = (@_ ? shift : caller) || subcroak "no path"; | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 1542 | ▶ | my $path = @_ ? shift : "main"; # subcroak "no path"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 1542 | ▶ | $path = blessed($path) if blessed($path); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 1542 | my @self = grep { length } split /(?:::|')/, $path; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 1542 | ▶ | shift @self while @self > 1 && $self[0] eq "main"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@self > 1 and $self[0] eq "main"
MC/DC0%0/2
@self > 1 and $self[0] eq "main"
@self > 1
$self[0] eq "main"
Truth table66%2/3
A and B
A= @self > 1B= $self[0] eq "main"
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 1542 | bless \@self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | ################################################################ | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | sub op_eq($$$) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 6 | ▶ | my($this, $that, $swapped) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_eq: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 6 | ▶ | use locale; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 6 | return "$this" eq "$that" | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub op_ne($$$) :method { !&op_eq } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_ne: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | sub op_cmp($$$) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | my($this, $that, $swapped) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_cmp: not called CC=3 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 6 | ▶ | no warnings "uninitialized"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 6 | ▶ | no overloading; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | for my $i (0 .. max $#$this, $#$that) { | |||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | return $this->[$i] cmp $that->[$i] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | unless $this->[$i] eq $that->[$i]; | ||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | sub op_spaceship($$$) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | my($this, $that, $swapped) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_spaceship: not called CC=2 SCAR=10.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 6 | ▶ | no overloading; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | return @$this <=> @$that | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | unless @$this == @$that; | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | goto \&op_cmp; # 👽 spaceships are permitted to use wormholes for speed | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | sub op_plus($$$) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 6 | ▶ | my($this, $that, $swapped) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_plus: called CC=5 SCAR=22.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 6 | ▶ | if (!blessed($that) && looks_like_number($that)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not builtin::blessed($that) and &looks_like_number($that)
MC/DC0%0/2
not builtin::blessed($that) and &looks_like_number($that)
not builtin::blessed($that)
&looks_like_number($that)
Truth table33%1/3
not(A) and B
A= not builtin::blessed($that)B= &looks_like_number($that)
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | return $this->length + $that; | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 6 | ▶ | unless($swapped) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 6 | return $this->add($that); | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | $that = PACKAGE($that) unless blessed $that; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | return $that->add($this); | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | sub op_minus($$$) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | my($this, $that, $swapped) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_minus: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | return $this if $that == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | return $this->super($that); | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | sub op_neg($) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | my($this) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_neg: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | return $this->left; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | ################################################################ | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | # this is useful in parallel situations (see subpackage, etc) | ||||||||||||||||||||||||||||||||||||||||||
| 139 | sub self :method { | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 74 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
self: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 74 | ▶ | @_ == 0 || subcroak "no arguments allowed"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 74 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 6 | *object = \&self; | |||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | sub class :method { | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
class: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | @_ == 0 || subcroak "no arguments allowed"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | return blessed($self) || $self; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
builtin::blessed($self) || $self
MC/DC0%0/2
builtin::blessed($self) || $self
builtin::blessed($self)
$self
Truth table0%0/3
A || B
A= builtin::blessed($self)B= $self
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | # Deconstructor to string | ||||||||||||||||||||||||||||||||||||||||||
| 154 | sub unbless :method { | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 716 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unbless: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 716 | ▶ | join("::", @$self) || "main"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 6 | *as_string = \&unbless; | |||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | # Deconstructor to array | ||||||||||||||||||||||||||||||||||||||||||
| 162 | sub split() :method { | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
split: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 6 | ▶ | @_ == 0 || subcroak "no arguments allowed"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 6 | ▶ | @$self ? @$self : "main"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 6 | *as_list = \&split; | |||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | # In case I someday change the implementation. | ||||||||||||||||||||||||||||||||||||||||||
| 170 | sub aref() :method { | ||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
aref: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | @_ == 0 || subcroak "no arguments allowed"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | return [ @$self ]; | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | sub length() :method { | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
length: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | 0 + @$self; | |||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | # The leftmost N portions, defaulting to 1 and maxing at length. | ||||||||||||||||||||||||||||||||||||||||||
| 182 | sub left(;$) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 348 | ▶ | my($self, $here) = &selfhere; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
left: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 348 | ▶ | @_ == 0 || subcroak "need one argument or none"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 348 | ▶ | return $self->new("main") if $here == -@$self; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 348 | my @self = @$self; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 348 | splice @self, $here; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 348 | return $self->new(@self); | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | sub left_but(;$) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 342 | ▶ | my($self, $here) = &selfhere; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
left_but: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 342 | ▶ | @_ == 0 || subcroak "need one argument or none"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 342 | $self->left(-$here); | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | # The rightmost N portions, defaulting to 1 and maxing at length. | ||||||||||||||||||||||||||||||||||||||||||
| 198 | sub right(;$) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 6 | ▶ | my($self, $here) = &selfhere; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
right: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 6 | ▶ | @_ == 0 || subcroak "need one argument or none"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 6 | ▶ | return $self->new("main") if $here == -@$self; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 6 | my @self = @$self; | |||||||||||||||||||||||||||||||||||||||||
| 203 | 6 | return $self->new(splice @self, -$here); | |||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | sub right_but(;$) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | my($self, $here) = &selfhere; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
right_but: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | @_ == 0 || subcroak "need one argument or none"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $self->right(-$here); | |||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | # The N-times super-package, defaulting to 1. | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 6 | *super = \&left_but; # even faster than goto :) | |||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | # Cuts the old object in two at the given position. By default | ||||||||||||||||||||||||||||||||||||||||||
| 216 | # splits at 1, so returns the dirname/superclass portion as the | ||||||||||||||||||||||||||||||||||||||||||
| 217 | # left and the basename/class portion as the right. | ||||||||||||||||||||||||||||||||||||||||||
| 218 | sub bisect(;$) : method { | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | my($self, $here) = &selfhere; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bisect: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | @_ == 0 || subcroak "need one argument or none"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my @self = @$self; | |||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my @right = splice @self, -$here; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | my $pair = [ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | $self->new(@self ? @self : "main"), | ||||||||||||||||||||||||||||||||||||||||||
| 225 | $self->new(@right ? @right : "main"), | ||||||||||||||||||||||||||||||||||||||||||
| 226 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | return wantarray ? @$pair : $pair; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | sub left_and_right(;$) : method { &bisect } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
left_and_right: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | sub right_and_left(;$) : method { | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | my($self, $here) = &selfhere; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
right_and_left: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | @_ == 0 || subcroak "need one argument or none"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $self->bisect(-$here); | |||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | # Construct subpackages, one for each argument. | ||||||||||||||||||||||||||||||||||||||||||
| 239 | # Must be called in list context if multiple args. | ||||||||||||||||||||||||||||||||||||||||||
| 240 | sub add(@) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 653 | ▶ | my($self, @new) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 653 | my @self = @$self; | |||||||||||||||||||||||||||||||||||||||||
| 243 | 653 | ▶ | @new > 0 || subcroak "need list of subpackages to generate"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 653 | ▶ | push @self, map { ref && reftype($_) eq "ARRAY" ? @$_ : $_ } @new; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $_ and builtin::reftype($_) eq "ARRAY"
MC/DC50%1/2
ref $_ and builtin::reftype($_) eq "ARRAY"
ref $_
builtin::reftype($_) eq "ARRAY"
Truth table66%2/3
A and B
A= ref $_B= builtin::reftype($_) eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 653 | $self->new(@self); | |||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | sub sib(@) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | my($self) = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sib: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | @_ > 0 || subcroak "need sibling package"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $self->super->add(@_); | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | sub add_all(@) { | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 430 | ▶ | my($self, @ends) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_all: called CC=5 SCAR=17.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 430 | ▶ | @ends > 0 || subcroak "need list of subpackages to generate"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 430 | ▶ | wantarray || @ends == 1 || subcroak "expected list context when generating multiple subpackages"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
wantarray or @ends == 1
MC/DC0%0/2
wantarray or @ends == 1
wantarray
@ends == 1
Truth table33%1/3
A or B
A= wantarrayB= @ends == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 430 | my @packs = map { $self->add($_) } @ends; | |||||||||||||||||||||||||||||||||||||||||
| 259 | 430 | ▶ | return wantarray ? @packs : $packs[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | sub add_all_unblessed { | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 430 | ▶ | my @pack_obs = &add_all; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_all_unblessed: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 430 | map { UNPACKAGE } @pack_obs; | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | sub span($$) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | @_ == 3 || subcroak "need 2 ordinals to span, not ".(@_-1)." of them"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
span: not called CC=11 SCAR=48.8
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my($self, $start) = &selfhere; | |||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | unshift @_, $self; | |||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | my(undef, $end) = &selfhere; | |||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | # forgive them | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | if ($start < 0 && $end < 0 && $end < $start) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$start < 0 and $end < 0 and $end < $start
$start < 0 and $end < 0
MC/DC0%0/3
$start < 0 and $end < 0 and $end < $start
$start < 0
$end < 0
$end < $start
Truth table0%0/4
A and B and C
A= $start < 0B= $end < 0C= $end < $start
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ($start, $end) | |||||||||||||||||||||||||||||||||||||||||
| 276 | = | ||||||||||||||||||||||||||||||||||||||||||
| 277 | ($end, $start) ; | ||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | if ($start > 0 && $end < 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$start > 0 and $end < 0
MC/DC0%0/2
$start > 0 and $end < 0
$start > 0
$end < 0
Truth table0%0/3
A and B
A= $start > 0B= $end < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | $end >= $start || subcroak "end argument $end should not be less than start argument $start"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | $end * $start > 0 || subcroak "span arguments $start and $end should have same sign"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if ($start > 0) { for ($start, $end) { $_-- } } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | $self->new( @$self [ $start .. $end ] ); | |||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | sub slice(@) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | @_ > 1 || subcroak "need one or more arguments"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
slice: not called CC=4 SCAR=30.0
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my($self, @here) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | for my $here (@here) { | |||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | (undef, $here) = selfhere($self, $here); | |||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | $here-- if $here > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $self->new(@$self[@here]); | |||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | sub snip($;$) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | @_ == 2 || @_ == 3 || subcroak "need either one or two arguments"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
snip: not called CC=6 SCAR=37.4
Pod
documented
Branch: 1 branch
Condition0%0/3
@_ == 2 or @_ == 3
MC/DC0%0/2
@_ == 2 or @_ == 3
@_ == 2
@_ == 3
Truth table0%0/3
A or B
A= @_ == 2B= @_ == 3
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my($self, $here) = &selfhere; | |||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | $here-- if $here > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | my @self = @$self; | |||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | if (my $end = shift) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my $count = $end - $here; | |||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | $count += @self if $count < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | #warn "splice(@self, $here, $count);"; | ||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | splice(@self, $here, $count); | |||||||||||||||||||||||||||||||||||||||||
| 310 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | splice(@self, $here); | |||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | $self->new(@self); | |||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | sub splice($;$@) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | @_ >= 2 || subcroak "need at least one argument"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
splice: not called CC=4 SCAR=30.0
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | my($self, $here) = &selfhere; | |||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | $here-- if $here > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | my @self = @$self; | |||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | if (my($count, @new) = @_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | splice(@self, $here, $count, @new); | |||||||||||||||||||||||||||||||||||||||||
| 323 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | splice(@self, $here); | |||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $self->new(@self); | |||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | # Why you would ever want to do this, I have no idea. | ||||||||||||||||||||||||||||||||||||||||||
| 331 | sub reverse($) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reverse: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | @_ == 0 || subcroak "no arguments allowed"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $self->new(CORE::reverse $self->split); | |||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | # Returns string, not object. | ||||||||||||||||||||||||||||||||||||||||||
| 338 | sub join($) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 339 | 6 | ▶ | @_ == 2 || subcroak "need one arg, not " . (@_-1); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
join: called CC=2 SCAR=7.0
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 341 | 6 | my $separator = shift; | |||||||||||||||||||||||||||||||||||||||||
| 342 | 6 | return CORE::join($separator, $self->split); | |||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | sub map(&) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | @_ == 2 || subcroak "need one arg, not " . (@_-1); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
map: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | my($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | $self->new(CORE::map(&$code, $self->split)); | |||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | # Returns new object(s)? and leaves original untouched. | ||||||||||||||||||||||||||||||||||||||||||
| 352 | sub grep(&) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | @_ == 2 || subcroak "need one arg, not " . (@_-1); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
grep: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | CORE::grep(&$code, $self->split); | |||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | # Returns string, not object. | ||||||||||||||||||||||||||||||||||||||||||
| 359 | sub abbreviate(;$) :method { | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | @_ <= 2 || subcroak "need either one argument or none, not " . (@_-1) . " of them"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
abbreviate: not called CC=3 SCAR=24.8
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | my $here = shift || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 1
MC/DC0%0/1
shift() || 1
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my($left, $right) = $self->bisect($here); | |||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | $left->map(sub { /^(\p{Lu})/ ? lc($1) : $_ })->add($right)->join(":"); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | # Returns string, not object. | ||||||||||||||||||||||||||||||||||||||||||
| 368 | 6 | ▶ | sub pmpath($) :method { shift->join("/").".pm" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pmpath: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | # Returns hash ref, not object. | ||||||||||||||||||||||||||||||||||||||||||
| 371 | sub stash($) { | ||||||||||||||||||||||||||||||||||||||||||
| 372 | 9 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stash: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 9 | ▶ | @_ == 0 || subcroak "no arguments allowed"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | 6 | ▶ | no strict "refs"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 9 | return \%{$self."::"}; | |||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | FindApp::Utils::Package::Object - FIXME | ||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | use FindApp::Utils::Package::Object; | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | =head2 Public Methods | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | =head3 C<abbreviate> | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | Returns a string where all package elements but the last two | ||||||||||||||||||||||||||||||||||||||||||
| 397 | have been abbreviated to a single lowercase letter. Used for | ||||||||||||||||||||||||||||||||||||||||||
| 398 | debugging output when the FINDAPP_DEBUG_SHORTEN environment variable is true. | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | $short = PACKAGE("FindApp::Utils::Package::Object::abbreviate"); | ||||||||||||||||||||||||||||||||||||||||||
| 401 | # $short now f:u:p:Object::abbreviate | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | =head3 C<< add(I<LIST>) >> | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | Returns a new object with the given arguments added as further components. | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | $start = PACKAGE("Three"); | ||||||||||||||||||||||||||||||||||||||||||
| 408 | $full = $start->add("Blind", "Mice"); | ||||||||||||||||||||||||||||||||||||||||||
| 409 | # $full now Three::Blind::Mice | ||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | =head3 C<< I<OBJ_LIST> = $obj->add_all(I<LIST>) >> | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | Returns a list of new objects, each with the original plus one element | ||||||||||||||||||||||||||||||||||||||||||
| 414 | in the argument list appended. | ||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | $pkg = PACKAGE("Spring::Field"); | ||||||||||||||||||||||||||||||||||||||||||
| 417 | @pkgs = $pkg->add_all("Ohio", "Iowa", "Maine"); | ||||||||||||||||||||||||||||||||||||||||||
| 418 | # Spring::Field::Ohio, Spring::Field::Iowa, Spring::Field::Maine | ||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | =head3 C<< I<STR_LIST> = $obj->add_all_unblessed(I<LIST>) >> | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | Like C<add_all> but returning strings not objects. | ||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | =head3 aref | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | Returns a reference to a copy of the object's package components. | ||||||||||||||||||||||||||||||||||||||||||
| 428 | Does not allow direct access to the original. | ||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | =head3 as_list | ||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | Returns a copy of the object's package components as a list. | ||||||||||||||||||||||||||||||||||||||||||
| 433 | Does not allow direct access to the original. | ||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | This is actually as alias for I<split>. | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | =head3 as_string | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | Returns a string of the object's package components joined with C<::>. | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | This is actually as alias for I<unbless>. | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | =head3 bisect I<ORDINAL> | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | Return two new objects which represent the original snipped at the | ||||||||||||||||||||||||||||||||||||||||||
| 446 | given I<ORDINAL> position. The I<ORDINAL> may be either positive | ||||||||||||||||||||||||||||||||||||||||||
| 447 | or negative, operating symmetrically. | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | For a positive I<ORDINAL>, count off starting from the B<right> end and then snip, | ||||||||||||||||||||||||||||||||||||||||||
| 450 | putting everything to the left of however far you got into the left | ||||||||||||||||||||||||||||||||||||||||||
| 451 | object returned and putting everything past where you got to in the | ||||||||||||||||||||||||||||||||||||||||||
| 452 | right object returned. | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | ($left, $right) = PACKAGE("A::B::C::D::E::F")->bisect(2); | ||||||||||||||||||||||||||||||||||||||||||
| 455 | # $left is A::B::C::D | ||||||||||||||||||||||||||||||||||||||||||
| 456 | # $right is E::F | ||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | ($left, $right) = PACKAGE("A::B::C::D::E::F")->bisect(4); | ||||||||||||||||||||||||||||||||||||||||||
| 459 | # $left is A::B | ||||||||||||||||||||||||||||||||||||||||||
| 460 | # $right is C::D::E::F | ||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | For a negative I<ORDINAL>, count off starting from the B<left> end and | ||||||||||||||||||||||||||||||||||||||||||
| 463 | then snip, B<still> putting everything to the left of however far you | ||||||||||||||||||||||||||||||||||||||||||
| 464 | got into the left object returned and putting everything past where you | ||||||||||||||||||||||||||||||||||||||||||
| 465 | got to in the right object returned. | ||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | ($left, $right) = PACKAGE("A::B::C::D::E::F")->bisect(-2); | ||||||||||||||||||||||||||||||||||||||||||
| 468 | # $left is A::B | ||||||||||||||||||||||||||||||||||||||||||
| 469 | # $right is C::D::E::F | ||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | ($left, $right) = PACKAGE("A::B::C::D::E::F")->bisect(-2); | ||||||||||||||||||||||||||||||||||||||||||
| 472 | # $left is A::B::C::D | ||||||||||||||||||||||||||||||||||||||||||
| 473 | # $right is E::F | ||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | Therefore the magnitude of a positive I<ORDINAL> represents how many | ||||||||||||||||||||||||||||||||||||||||||
| 476 | elements are returned in the right object, while the magnitude of a | ||||||||||||||||||||||||||||||||||||||||||
| 477 | negative I<ORDINAL> represents how many elements are returned in the | ||||||||||||||||||||||||||||||||||||||||||
| 478 | left object. If you find this hard to remember or keep straight, | ||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | =head3 class | ||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||
| 482 | Returns the invocant class. | ||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | =head3 grep I<CODE_REF> | ||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||
| 486 | Returns a list of package components for which the code reference | ||||||||||||||||||||||||||||||||||||||||||
| 487 | expression tests true on as they were each set to C<$_> in succession. | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | say for PACKAGE("Red::Riding::Hood")->grep(sub{/^R/}); | ||||||||||||||||||||||||||||||||||||||||||
| 490 | # Red | ||||||||||||||||||||||||||||||||||||||||||
| 491 | # Riding | ||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | =head3 join I<STRING> | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | Returns a string with the package elements connected by its argument. | ||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | say PACKAGE("Red::Riding::Hood")->join("!") | ||||||||||||||||||||||||||||||||||||||||||
| 498 | # Red!Riding!Hood | ||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||
| 500 | =head3 left I<ORDINAL> | ||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | Returns a new object that has the leftmost I<ORDINAL> elements in it. | ||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | $head = PACKAGE("A::B::C::D::E::F")->left(2); | ||||||||||||||||||||||||||||||||||||||||||
| 505 | # $head is A::B | ||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | If a negative index is supplied, all B<but> that many | ||||||||||||||||||||||||||||||||||||||||||
| 508 | right elements are returned. | ||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | $tail = PACKAGE("A::B::C::D::E::F")->left(-2); | ||||||||||||||||||||||||||||||||||||||||||
| 511 | # $tail is A::B::C::D | ||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | This method have been called I<first> or I<top> or I<head> or even | ||||||||||||||||||||||||||||||||||||||||||
| 514 | I<pull> or I<unshift>, but I<left> seemed to be the least confusing, | ||||||||||||||||||||||||||||||||||||||||||
| 515 | especially once negatives are included. | ||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | =head3 left_and_right I<ORDINAL> | ||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | Returns two objects representing the left and right parts of the original. | ||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||
| 521 | When I<ORDINAL> is positive, it specifies how many elements will be in | ||||||||||||||||||||||||||||||||||||||||||
| 522 | the right return object. | ||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||
| 524 | When I<ORDINAL> is negative, its magnitude | ||||||||||||||||||||||||||||||||||||||||||
| 525 | specifies how many elements will be in the left return object. | ||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | ($left, $right) = PACKAGE("A::B::C::D::E::F")->left_and_right(2); | ||||||||||||||||||||||||||||||||||||||||||
| 528 | # $left is A::B::C::D | ||||||||||||||||||||||||||||||||||||||||||
| 529 | # $right is E::F | ||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | ($left, $right) = PACKAGE("A::B::C::D::E::F")->left_and_right(-2); | ||||||||||||||||||||||||||||||||||||||||||
| 532 | # $left is A::B | ||||||||||||||||||||||||||||||||||||||||||
| 533 | # $right is C::D::E::F | ||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | (Same as C<bisect>, but easier to remember.) | ||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | =head3 left_but I<ORDINAL> | ||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | Returns a new object that has all B<but> the last I<ORDINAL> elements | ||||||||||||||||||||||||||||||||||||||||||
| 540 | in it. So here you get all left bits but for the last two of them: | ||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||
| 542 | $front = PACKAGE("A::B::C::D::E::F")->left_but(2); | ||||||||||||||||||||||||||||||||||||||||||
| 543 | # $front is A::B::C::D | ||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | This method exists so you don't have to remember negatives; it just | ||||||||||||||||||||||||||||||||||||||||||
| 546 | calls I<left> with the sign of its argument flipped. Negatives | ||||||||||||||||||||||||||||||||||||||||||
| 547 | therefore work symmetrically: | ||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||
| 549 | $front = PACKAGE("A::B::C::D::E::F")->left_but(-2); | ||||||||||||||||||||||||||||||||||||||||||
| 550 | # $front is A::B | ||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | Negative ordinals mean to keep only that many rather than to discard that many: | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | $front = PACKAGE("A::B::C::D::E::F")->left_but(-2); | ||||||||||||||||||||||||||||||||||||||||||
| 556 | # $front is A::B | ||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | The C<left_but(I<N>)> method is really the C<left(I<-N>)> method so that you | ||||||||||||||||||||||||||||||||||||||||||
| 559 | don't have to think about negative ordinals. | ||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | =head3 length | ||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | Returns the number of package elements. | ||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | $count = PACKAGE("A::B::C::D::E::F")->length; | ||||||||||||||||||||||||||||||||||||||||||
| 566 | # $count is now 6. | ||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||
| 568 | This is the method used for the C<0+> operator overload. | ||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||
| 570 | =head3 map I<CODE_REF> | ||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | Returns a new object each of whose path components is the result | ||||||||||||||||||||||||||||||||||||||||||
| 573 | of running the given code against. | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | $small = PACKAGE("A::B::C")->map(sub{lc}); | ||||||||||||||||||||||||||||||||||||||||||
| 576 | # $small is a::b::c | ||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||
| 578 | =head3 new I<LIST> | ||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||
| 580 | This is the general class constructor. | ||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||
| 582 | $class = "FindApp::Utils::Package::Object"; | ||||||||||||||||||||||||||||||||||||||||||
| 583 | $ob = $class->new("A::B::C"); | ||||||||||||||||||||||||||||||||||||||||||
| 584 | # $ob now has length 3 | ||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||
| 586 | If multiple arguments are given, they concatenate: | ||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||
| 588 | $ob = $class->new("A" .. Z"); | ||||||||||||||||||||||||||||||||||||||||||
| 589 | # $ob has length 26 | ||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | The single-quote version of the package separator is tolerated | ||||||||||||||||||||||||||||||||||||||||||
| 592 | on input, but the canonical form is always produced on output: | ||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||
| 594 | $ob = $class->new("you", "shouldn't've"); | ||||||||||||||||||||||||||||||||||||||||||
| 595 | # $ob is now you::shouldn::t::ve | ||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | Because the package name C<FindApp::Utils::Package::Object> is so | ||||||||||||||||||||||||||||||||||||||||||
| 598 | long, the I<PACKAGE> alias for the constructor is normally used. | ||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||
| 600 | =head3 object | ||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||
| 602 | Returns the invocant. | ||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||
| 604 | =head3 op_cmp | ||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||
| 606 | This is the method used for the overloaded C<cmp> operator. It | ||||||||||||||||||||||||||||||||||||||||||
| 607 | runs a normal C<cmp> operation on each element left to right. | ||||||||||||||||||||||||||||||||||||||||||
| 608 | That means that "AB::CD::EF" will sort earlier than "ABC::DEF" | ||||||||||||||||||||||||||||||||||||||||||
| 609 | because "AB" sorts before "ABC". The first element that differs | ||||||||||||||||||||||||||||||||||||||||||
| 610 | is what counts. | ||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||
| 612 | See the L<op_spaceship> method if you want it to work the other way. | ||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||
| 614 | In other words, it only uses the real C<cmp> operator on each element | ||||||||||||||||||||||||||||||||||||||||||
| 615 | iteratively until one fails. It does not compare the entire package as | ||||||||||||||||||||||||||||||||||||||||||
| 616 | one string. | ||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||
| 618 | =head3 op_eq | ||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||
| 620 | This is the method used for the overloaded C<eq> operator. | ||||||||||||||||||||||||||||||||||||||||||
| 621 | It compares the two strings in full using the regular C<eq>. | ||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||
| 623 | =head3 op_equals | ||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | This is the method used for the overloaded C<==> operator. | ||||||||||||||||||||||||||||||||||||||||||
| 626 | It is used for checking whether two objects are the same | ||||||||||||||||||||||||||||||||||||||||||
| 627 | object by comparing their reference's addresses numerically. | ||||||||||||||||||||||||||||||||||||||||||
| 628 | It returns true if their refaddrs are the same. | ||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||
| 630 | It's really the method of that name imported from L<FindApp::Utils::Objects>. | ||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | =head3 op_minus | ||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||
| 634 | This is the method used for the overloaded binary C<-> operator, | ||||||||||||||||||||||||||||||||||||||||||
| 635 | the infix one. | ||||||||||||||||||||||||||||||||||||||||||
| 636 | It is the same as calling the I<super> method with its numeric | ||||||||||||||||||||||||||||||||||||||||||
| 637 | argument, so throws away that many elements from the right and | ||||||||||||||||||||||||||||||||||||||||||
| 638 | returns a new object. | ||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||
| 640 | $ob = PACKAGE("usr::bin::perl"); | ||||||||||||||||||||||||||||||||||||||||||
| 641 | print $ob - 1; | ||||||||||||||||||||||||||||||||||||||||||
| 642 | # prints usr::bin | ||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||
| 644 | This is also used for derived C<-=> and C<--> operators. | ||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||
| 646 | =head3 op_ne | ||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||
| 648 | This is the method used for the overloaded C<ne> operator. | ||||||||||||||||||||||||||||||||||||||||||
| 649 | It is simply the reverse of the C<eq> operator. | ||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||
| 651 | =head3 op_neg | ||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||
| 653 | This is the method used for the overloaded unary C<-> operator, | ||||||||||||||||||||||||||||||||||||||||||
| 654 | the prefix one. It's a quick way to get the leftmost element. | ||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | $ob = PACKAGE("usr::bin::perl"); | ||||||||||||||||||||||||||||||||||||||||||
| 657 | print -$ob; | ||||||||||||||||||||||||||||||||||||||||||
| 658 | # prints "usr" | ||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||
| 660 | =head3 op_notequals | ||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||
| 662 | This is the method used for the overloaded C<!=> operator. | ||||||||||||||||||||||||||||||||||||||||||
| 663 | It is used for checking whether two objects are different | ||||||||||||||||||||||||||||||||||||||||||
| 664 | objects by comparing their reference's addresses numerically. | ||||||||||||||||||||||||||||||||||||||||||
| 665 | It returns true if their refaddrs are not the same number. | ||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||
| 667 | It's really the method of that name imported from L<FindApp::Utils::Objects>. | ||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||
| 669 | =head3 op_plus | ||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||
| 671 | This is the method used for the overloaded binary C<+> operator. | ||||||||||||||||||||||||||||||||||||||||||
| 672 | As you might expect, it returns a new object that has the right operand | ||||||||||||||||||||||||||||||||||||||||||
| 673 | concatenated to the end of the left operand in that order. | ||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||
| 675 | print PACKAGE("A::B") + PACKAGE("X::Y"); | ||||||||||||||||||||||||||||||||||||||||||
| 676 | # prints A::B::X::Y | ||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||
| 678 | It is not associative, since ordering matters. | ||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||
| 680 | =head3 op_spaceship | ||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||
| 682 | This is the method used for the overloaded C<< <=> >> operator. | ||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||
| 684 | It first compares the numbers of elements in each operand as numbers, | ||||||||||||||||||||||||||||||||||||||||||
| 685 | and only if those are the same does it then go on compare the respective | ||||||||||||||||||||||||||||||||||||||||||
| 686 | pieces as strings. That means that shorter package counts sort earlier | ||||||||||||||||||||||||||||||||||||||||||
| 687 | even if they have later letters. So all one-element packages would sort | ||||||||||||||||||||||||||||||||||||||||||
| 688 | before all two-element ones, and so on. | ||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||
| 690 | PACKAGE("AB::CD::EF") <=> PACKAGE("ABC::DEF") # 1 | ||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||
| 692 | That returns 1 because the first has three elements and the second has two. | ||||||||||||||||||||||||||||||||||||||||||
| 693 | See the L<op_cmp> method if you want it to work the other way by comparing | ||||||||||||||||||||||||||||||||||||||||||
| 694 | "AB" with "ABC". | ||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||
| 696 | Another way to think of it is that C<< $a <=> $b >> is that is works like | ||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||
| 698 | $a->length <=> $b->length | ||||||||||||||||||||||||||||||||||||||||||
| 699 | || | ||||||||||||||||||||||||||||||||||||||||||
| 700 | $a cmp $b | ||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||
| 702 | In other words, the real C<< <=> >> operator is used only for comparing | ||||||||||||||||||||||||||||||||||||||||||
| 703 | lengths. If the lengths are the same, then C<cmp> operator is used one | ||||||||||||||||||||||||||||||||||||||||||
| 704 | package element at a time. | ||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||
| 706 | =head3 pmpath | ||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||
| 708 | This method converts the package object into a path sting by swapping | ||||||||||||||||||||||||||||||||||||||||||
| 709 | the double colons out for slashes and appending ".pm" to the end. | ||||||||||||||||||||||||||||||||||||||||||
| 710 | It's just there to give a name to this simple operation: | ||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||
| 712 | $obj->join("/").".pm" | ||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||
| 714 | =head3 reverse | ||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||
| 716 | Returns a new object with all its elements laid out the other | ||||||||||||||||||||||||||||||||||||||||||
| 717 | direction. | ||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||
| 719 | PACKAGE("AB::CD::EF")->reverse | ||||||||||||||||||||||||||||||||||||||||||
| 720 | # produces ED::CD::AB | ||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||
| 722 | =head3 right I<ORDINAL> | ||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||
| 724 | Returns a new object that has the rightmost I<ORDINAL> elements in it. | ||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||
| 726 | $tail = PACKAGE("A::B::C::D::E::F")->right(2); | ||||||||||||||||||||||||||||||||||||||||||
| 727 | # $head is E::F | ||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||
| 729 | If a negative index is supplied, all B<but> that many | ||||||||||||||||||||||||||||||||||||||||||
| 730 | left elements are returned. | ||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||
| 732 | $head = PACKAGE("A::B::C::D::E::F")->right(-2); | ||||||||||||||||||||||||||||||||||||||||||
| 733 | # $tail is A::B::C::D | ||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||
| 735 | This method have been called I<last> or I<pop> or I<tail>. | ||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||
| 737 | =head3 right_and_left I<ORDINAL> | ||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||
| 739 | Returns two objects representing the left and right parts of the | ||||||||||||||||||||||||||||||||||||||||||
| 740 | original, in that order. When I<ORDINAL> is positive, it specifies how | ||||||||||||||||||||||||||||||||||||||||||
| 741 | many elements will be in the left return object. When I<ORDINAL> is | ||||||||||||||||||||||||||||||||||||||||||
| 742 | negative, its magnitude specifies how many elements will be in the right | ||||||||||||||||||||||||||||||||||||||||||
| 743 | return object. | ||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||
| 745 | ($left, $right) = PACKAGE("A::B::C::D::E::F")->right_and_left(2); | ||||||||||||||||||||||||||||||||||||||||||
| 746 | # $left is A::B | ||||||||||||||||||||||||||||||||||||||||||
| 747 | # $right is C::D::E::F | ||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||
| 749 | ($left, $right) = PACKAGE("A::B::C::D::E::F")->right_and_left(-2); | ||||||||||||||||||||||||||||||||||||||||||
| 750 | # $left is A::B::C::D | ||||||||||||||||||||||||||||||||||||||||||
| 751 | # $right is E::F | ||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||
| 753 | This method exists so you don't have to think about negative ordinals, | ||||||||||||||||||||||||||||||||||||||||||
| 754 | but it is potentially confusing because you get back the left first | ||||||||||||||||||||||||||||||||||||||||||
| 755 | and the right second even though those words occur in the opposite | ||||||||||||||||||||||||||||||||||||||||||
| 756 | order in the name of the method. Just remember that whichever word | ||||||||||||||||||||||||||||||||||||||||||
| 757 | has the number near it is how many of that you get. | ||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||
| 759 | =head3 right_but I<ORDINAL> | ||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||
| 761 | Returns a new object that has all B<but> the first I<ORDINAL> elements | ||||||||||||||||||||||||||||||||||||||||||
| 762 | in it. So here you get all the right bits but for the first two of them: | ||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||
| 764 | $back = PACKAGE("A::B::C::D::E::F")->right_but(2); | ||||||||||||||||||||||||||||||||||||||||||
| 765 | # $back is C::D::E::F | ||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||
| 767 | Negative ordinals keep only that many rather than to discard that many: | ||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||
| 769 | $back = PACKAGE("A::B::C::D::E::F")->right_but(-2); | ||||||||||||||||||||||||||||||||||||||||||
| 770 | # $back is E::F | ||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||
| 772 | The C<right_but(I<N>)> method is really the C<right(I<-N>)> method so that you | ||||||||||||||||||||||||||||||||||||||||||
| 773 | don't have to think about negative ordinals. | ||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||
| 775 | =head3 self | ||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||
| 777 | Returns the object itself. Dies if invoked on a class. | ||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||
| 779 | =head3 sib I<NAME> | ||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||
| 781 | Returns a new object which is the named "sibling" package of the one specified. | ||||||||||||||||||||||||||||||||||||||||||
| 782 | So for example if your package is A::B::C, then your super is A::B and represents | ||||||||||||||||||||||||||||||||||||||||||
| 783 | your parent, and if you had a sibling named J, that would be A::B::J. | ||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||
| 785 | $sib = PACKAGE("A::B::C")->sib("J"); | ||||||||||||||||||||||||||||||||||||||||||
| 786 | # $sub is A::B::J | ||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||
| 788 | It only returns one result no matter how many arguments you supply; if | ||||||||||||||||||||||||||||||||||||||||||
| 789 | you pass more than one I<NAME>, these are each separate elements in the | ||||||||||||||||||||||||||||||||||||||||||
| 790 | one return object: | ||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||
| 792 | $sib = PACKAGE("A::B::C")->sib("J","K"); | ||||||||||||||||||||||||||||||||||||||||||
| 793 | $ $sib is A::B::J::K. | ||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||
| 795 | =head3 slice I<INDICES> | ||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||
| 797 | Returns a new object selecting only those elements whose ordinals you specify | ||||||||||||||||||||||||||||||||||||||||||
| 798 | in the argument list. Positive ordinals count from the left and negatives | ||||||||||||||||||||||||||||||||||||||||||
| 799 | ones from the right. | ||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||
| 801 | $class = "FindApp::Utils::Package::Object"; | ||||||||||||||||||||||||||||||||||||||||||
| 802 | $abc_obj = $class->new("A" .. "Z"); | ||||||||||||||||||||||||||||||||||||||||||
| 803 | # $abc_obj is A::B::C::D::E::F::G::H::I::J::K::L::M::N::O::P::Q::R::S::T::U::V::W::X::Y::Z | ||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||
| 805 | print $abc_obj->slice(1,3,-3,-1); | ||||||||||||||||||||||||||||||||||||||||||
| 806 | # prints A::C::X::Z | ||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||
| 808 | =head3 snip I<START>, I<END> | ||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||
| 810 | Returns a new object formed by joining portion to left of the I<START> | ||||||||||||||||||||||||||||||||||||||||||
| 811 | ordinal to the portion to the right of the I<END> ordinal in the original | ||||||||||||||||||||||||||||||||||||||||||
| 812 | package elements. | ||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||
| 814 | =head3 span I<START>, I<END> | ||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||
| 816 | Returns a new object consisting of a span of all the original package | ||||||||||||||||||||||||||||||||||||||||||
| 817 | elements starting with the I<START> ordinal and ending with the I<END> | ||||||||||||||||||||||||||||||||||||||||||
| 818 | ordinal. The second argument must not be less than the first argument. | ||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||
| 820 | $class = "FindApp::Utils::Package::Object"; | ||||||||||||||||||||||||||||||||||||||||||
| 821 | $abc_obj = $class->new("A" .. "Z"); | ||||||||||||||||||||||||||||||||||||||||||
| 822 | # $abc_obj is A::B::C::D::E::F::G::H::I::J::K::L::M::N::O::P::Q::R::S::T::U::V::W::X::Y::Z | ||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||
| 824 | print $abc_obj->span(1, 4); | ||||||||||||||||||||||||||||||||||||||||||
| 825 | # prints A::B::C::D | ||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||
| 827 | print $abc_obj->span(-4, -1); | ||||||||||||||||||||||||||||||||||||||||||
| 828 | # prints W::X::Y::Z | ||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||
| 830 | print $abc_obj->span(4, 8); | ||||||||||||||||||||||||||||||||||||||||||
| 831 | # prints D::E::F::G::H | ||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||
| 833 | As a special dispensation for a common mistake, if both arguments | ||||||||||||||||||||||||||||||||||||||||||
| 834 | are negative but the second is greater than the first, then you | ||||||||||||||||||||||||||||||||||||||||||
| 835 | must have reversed the arguments by accident and so the method | ||||||||||||||||||||||||||||||||||||||||||
| 836 | flips them back as though you had written them correctly. | ||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||
| 838 | # means span(-4, -1) | ||||||||||||||||||||||||||||||||||||||||||
| 839 | print $abc_obj->span(-1, -4); | ||||||||||||||||||||||||||||||||||||||||||
| 840 | # prints W::X::Y::Z | ||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||
| 842 | =head3 splice I<START>, I<END> | ||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||
| 844 | =head3 splice I<START> | ||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||
| 846 | Returns a new object with everything between I<START> | ||||||||||||||||||||||||||||||||||||||||||
| 847 | and I<END> deleted. If I<END> is omitted, everything | ||||||||||||||||||||||||||||||||||||||||||
| 848 | till the end is deleted. | ||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||
| 850 | =head3 split | ||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||
| 852 | =head3 stash | ||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||
| 854 | =head3 super | ||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||
| 856 | =head3 unbless | ||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||
| 858 | =head2 Exports | ||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||
| 860 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||
| 862 | =item PACKAGE(;$) | ||||||||||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||||||||||
| 864 | =item UNPACKAGE(_) | ||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||
| 866 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||
| 868 | =head2 Sorting | ||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||
| 870 | resorting the dict-sorted ABBA AB::CD A::B::C::D::E::F A::B::CD::EF A::B::CDEF A::BC::D::EF A::BCD::E::F AB::CD::EF ABC::DEF | ||||||||||||||||||||||||||||||||||||||||||
| 871 | sort {cmp} packages: A::B::C::D::E::F A::B::CD::EF A::B::CDEF A::BC::D::EF A::BCD::E::F AB::CD AB::CD::EF ABBA ABC::DEF | ||||||||||||||||||||||||||||||||||||||||||
| 872 | sort {<=>} packages: ABBA AB::CD ABC::DEF A::B::CDEF AB::CD::EF A::B::CD::EF A::BC::D::EF A::BCD::E::F A::B::C::D::E::F | ||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||
| 875 | =head1 EXAMPLES | ||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||
| 877 | =head1 ENVIRONMENT | ||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||
| 879 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||
| 881 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||
| 883 | =item L<FindApp> | ||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||
| 885 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||
| 887 | =head1 CAVEATS AND PROVISOS | ||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||
| 889 | =head1 BUGS AND LIMITATIONS | ||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||
| 891 | =head1 HISTORY | ||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||
| 893 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||
| 895 | Tom Christiansen << <tchrist@perl.com> >> | ||||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||
| 897 | =head1 LICENCE AND COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||||||||||||||||
| 899 | Copyright (c) 2016, Tom Christiansen C<< <tchrist@perl.com> >>. | ||||||||||||||||||||||||||||||||||||||||||
| 900 | All Rights Reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||
| 902 | This module is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||||||||||||
| 903 | modify it under the same terms as Perl itself. See L<perlartistic>. | ||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||
| 905 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||