From ec725fc2c2817640eeb4840dc47b256fb5910291 Mon Sep 17 00:00:00 2001 From: miker Date: Thu, 22 Jun 2006 19:06:47 +0000 Subject: [PATCH] adding a tree filter for future common use git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@739 9efc2488-bf62-4759-914b-345cdb29e865 --- src/perlmods/OpenSRF/Utils.pm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/perlmods/OpenSRF/Utils.pm b/src/perlmods/OpenSRF/Utils.pm index 36e794d..90c73f4 100644 --- a/src/perlmods/OpenSRF/Utils.pm +++ b/src/perlmods/OpenSRF/Utils.pm @@ -39,7 +39,7 @@ our $date_parser = DateTime::Format::ISO8601->new; #$Storable::forgive_me = 1; %EXPORT_TAGS = ( - common => [qw(interval_to_seconds seconds_to_interval sendmail)], + common => [qw(interval_to_seconds seconds_to_interval sendmail tree_filter)], daemon => [qw(safe_fork set_psname daemonize)], datetime => [qw(clense_ISO8601 gmtime_ISO8601 interval_to_seconds seconds_to_interval)], ); @@ -77,6 +77,19 @@ sub _sub_builder { } } +sub tree_filter { + my $tree = shift; + my $field = shift; + my $filter = shift; + + my @things = $filter->($tree); + for my $v ( @{$tree->$field} ){ + push @things, $filter->($v); + push @things, tree_filter($v, $field, $filter); + } + return @things +} + #sub standalone_ipc_cache { # my $self = shift; # my $class = ref($self) || $self; -- 2.11.0