| 1 | package Catmandu::Fix::compact; | ||
| 2 | |||
| 3 | 1 | ▶ | use Catmandu::Sane; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 1 | our $VERSION = '1.2025'; | |
| 6 | |||
| 7 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use Catmandu::Util::Path qw(as_path); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 1 | ▶ | use Catmandu::Fix::Has; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 1 | with 'Catmandu::Fix::Builder'; | |
| 12 | |||
| 13 | 1 | has path => (fix_arg => 1); | |
| 14 | |||
| 15 | 1 | ▶ | sub _build_fixer { |
|
Subroutine
_build_fixer: called CC=1 SCAR=0.0
| |||
| 16 | 1 | my ($self) = @_; | |
| 17 | as_path($self->path) | ||
| 18 | 1 | ▶ | ->updater(if_array_ref => sub {[grep defined, @{$_[0]}]}); |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 19 | } | ||
| 20 | |||
| 21 | =head1 NAME | ||
| 22 | |||
| 23 | Catmandu::Fix::compact - remove undefined values from an array | ||
| 24 | |||
| 25 | =head1 SYNOPSIS | ||
| 26 | |||
| 27 | # list => [undef,"hello",undef,"world"] | ||
| 28 | compact(list) | ||
| 29 | # list => ["Hello","world"] | ||
| 30 | |||
| 31 | =head1 SEE ALSO | ||
| 32 | |||
| 33 | L<Catmandu::Fix> | ||
| 34 | |||
| 35 | =cut | ||
| 36 | |||
| 37 | 1 | 1; | |