| 1 | package Neovim::Ext::Common; | ||||||||||
| 2 | 55 | $Neovim::Ext::Common::VERSION = '0.01'; | |||||||||
| 3 | 55 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 55 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 55 | ▶ | use Exporter 'import'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 55 | our @EXPORT_OK = qw/walk/; | |||||||||
| 8 | |||||||||||
| 9 | |||||||||||
| 10 | sub walk | ||||||||||
| 11 | { | ||||||||||
| 12 | 48 | ▶ | my ($sub, $obj, @args) = @_; | ||||||||
|
Subroutine
walk: called CC=4 SCAR=16.8
Pod
documented
| |||||||||||
| 13 | |||||||||||
| 14 | 48 | ▶ | if (ref ($obj) eq 'ARRAY') | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | { | ||||||||||
| 16 | 19 | return [map { walk ($sub, $_, @args) } @$obj]; | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 29 | ▶ | if (ref ($obj) eq 'HASH') | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | { | ||||||||||
| 21 | 0 | my %result; | |||||||||
| 22 | 0 | ▶ | while (my ($key, $value) = each %$obj) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | { | ||||||||||
| 24 | 0 | $result{walk ($sub, $key, @args)} = walk ($sub, $value, @args); | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 0 | return \%result; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 29 | return $sub->($obj, @args); | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | =head1 NAME | ||||||||||
| 34 | |||||||||||
| 35 | Neovim::Ext::Common - Common functions | ||||||||||
| 36 | |||||||||||
| 37 | =head1 VERSION | ||||||||||
| 38 | |||||||||||
| 39 | version 0.01 | ||||||||||
| 40 | |||||||||||
| 41 | =head1 FUNCTIONS | ||||||||||
| 42 | |||||||||||
| 43 | =head2 walk( \&sub, $obj, @args) | ||||||||||
| 44 | |||||||||||
| 45 | Walk C<$obj> recursively, calling C<\&sub> with C<$obj> and C<@args>. | ||||||||||
| 46 | |||||||||||
| 47 | =cut | ||||||||||
| 48 | |||||||||||
| 49 | 55 | 1; | |||||||||