Data-Find
view release on metacpan or search on metacpan
lib/Data/Find.pm view on Meta::CPAN
push @got, $path;
}
return @got;
}
=head2 C<dwith>
Similar to C<diter> but call a supplied callback with each
matching path.
dwith $data, qr/nice/, sub {
my ( $path, $obj ) = @_;
print "$path, $obj\n";
};
=cut
sub dwith {
my $cb = pop @_;
my $iter = diter @_;
while ( my ( $path, $obj ) = $iter->() ) {
$cb->( $path, $obj );
}
return;
}
sub _mk_matcher {
my $match = shift;
if ( ref $match ) {
if ( 'CODE' eq ref $match ) {
return $match;
}
elsif ( 'Regexp' eq ref $match ) {
return sub {
my $v = shift;
return unless defined $v && !ref $v;
return $v =~ $match;
};
}
}
if ( defined $match ) {
return sub { shift eq $match };
}
return sub { !defined shift }
}
sub _fmt_key {
my $key = shift;
return $key if $key =~ /^(?:\d+|[a-z]\w*)$/i;
chomp( my $rep
= Data::Dumper->new( [$key] )->Purity( 1 )->Useqq( 1 )->Terse( 1 )
->Dump );
return $rep;
}
1;
__END__
=head1 BUGS AND LIMITATIONS
No bugs have been reported.
Please report any bugs or feature requests to
C<bug-data-find@rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org>.
=head1 AUTHOR
Andy Armstrong C<< <andy@hexten.net> >>
=head1 LICENCE AND COPYRIGHT
Copyright (c) 2009, Andy Armstrong C<< <andy@hexten.net> >>.
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlartistic>.
( run in 2.637 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )