| 1 | package Catmandu::Fix::split_field; | ||
| 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 Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use namespace::clean; |
|
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 | has path => (fix_arg => 1); | |
| 12 | 0 | ▶ | has split_char => (fix_arg => 1, default => sub {qr'\s+'}); |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 13 | |||
| 14 | 1 | with 'Catmandu::Fix::SimpleGetValue'; | |
| 15 | |||
| 16 | sub emit_value { | ||
| 17 | 3 | ▶ | my ($self, $var, $fixer) = @_; |
|
Subroutine
emit_value: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 18 | 3 | my $split_char = $fixer->emit_string($self->split_char); | |
| 19 | |||
| 20 | 3 | "${var} = [split ${split_char}, ${var}] if is_value(${var});"; | |
| 21 | } | ||
| 22 | |||
| 23 | 1 | 1; | |
| 24 | |||
| 25 | __END__ | ||
| 26 | |||
| 27 | =pod | ||
| 28 | |||
| 29 | =head1 NAME | ||
| 30 | |||
| 31 | Catmandu::Fix::split_field - split a string value in a field into an ARRAY | ||
| 32 | |||
| 33 | =head1 SYNOPSIS | ||
| 34 | |||
| 35 | # Split the 'foo' value into an array. E.g. foo => '1:2:3' | ||
| 36 | split_field(foo, ':') # foo => [1,2,3] | ||
| 37 | |||
| 38 | =head1 SEE ALSO | ||
| 39 | |||
| 40 | L<Catmandu::Fix> | ||
| 41 | |||
| 42 | =cut | ||