| 1 | package Catmandu::Fix::uniq; | ||
| 2 | |||
| 3 | 1 | ▶ | use Catmandu::Sane; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 1 | our $VERSION = '1.0201_02'; | |
| 6 | |||
| 7 | 1 | ▶ | use List::MoreUtils (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 1 | ▶ | use namespace::clean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 1 | ▶ | use Catmandu::Fix::Has; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 1 | has path => (fix_arg => 1); | |
| 13 | |||
| 14 | 1 | with 'Catmandu::Fix::SimpleGetValue'; | |
| 15 | |||
| 16 | sub emit_value { | ||
| 17 | 1 | ▶ | my ($self, $var, $fixer) = @_; |
|
Subroutine
emit_value: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 18 | |||
| 19 | 1 | "if (is_array_ref(${var})) {" | |
| 20 | . "no warnings 'uninitialized';" | ||
| 21 | . "${var} = [List::MoreUtils::uniq(\@{${var}})];" . "}"; | ||
| 22 | } | ||
| 23 | |||
| 24 | 1 | 1; | |
| 25 | |||
| 26 | __END__ | ||
| 27 | |||
| 28 | =pod | ||
| 29 | |||
| 30 | =head1 NAME | ||
| 31 | |||
| 32 | Catmandu::Fix::uniq - strip duplicate values from an array | ||
| 33 | |||
| 34 | =head1 SYNOPSIS | ||
| 35 | |||
| 36 | # {tags => ["foo", "bar", "bar", "foo"]} | ||
| 37 | uniq(tags) | ||
| 38 | # {tags => ["foo", "bar"]} | ||
| 39 | |||
| 40 | =head1 SEE ALSO | ||
| 41 | |||
| 42 | L<Catmandu::Fix> | ||
| 43 | |||
| 44 | =cut | ||