Perl Diver 2.33
Main Environment Variables Perl Default Values Perl Config - Summary Perl Config - Full Installed Modules List Directory uptime Docs

Module Documentation
Details and documentation about a specific module, including version and documentation (if available). Note that while links to perldoc.com and search.cpan.org are provided, the module may be part of a larger distribution. If you reach a File Not Found page on either site, please try the parent module.

XML::Grove::Sub

Name XML::Grove::Sub
Version
Located at /usr/share/perl5
File /usr/share/perl5/XML/Grove/Sub.pm
Is Core No
Search CPAN for this module XML::Grove::Sub
Documentation XML::Grove::Sub
Module Details XML::Grove::Sub

NAME

XML::Grove::Sub - run a filter sub over a grove


SYNOPSIS

 use XML::Grove::Sub;
 # Using filter method on XML::Grove::Document or XML::Grove::Element:
 @results = $grove_object->filter(\&sub [, ...]);
 # Using an XML::Grove::Sub instance:
 $filterer = XML::Grove::Sub->new();
 @results = $grove_object->accept($filterer, \&sub [, ...]);


DESCRIPTION

XML::Grove::Sub executes a sub, the filter, over all objects in a grove and returns a list of all the return values from the sub. The sub is called with the grove object as it's first parameter and passing the rest of the arguments to the call to `filter()' or `accept()'.


EXAMPLE

The following filter will return a list of all `foo' or `bar' elements with an attribute `widget-no' beginning with `A' or `B'.

  @results = $grove_obj->filter(sub {
      my $obj = shift;
      if ($obj->isa('XML::Grove::Element')
          && (($obj->{Name} eq 'foo')
              || ($obj->{Name} eq 'bar'))
          && ($obj->{Attributes}{'widget-no'} =~ /^[AB]/)) {
          return ($obj);
      }
      return ();
  });


AUTHOR

Ken MacLeod, ken@bitsko.slc.ut.us


SEE ALSO

perl(1), XML::Grove(3), Data::Grove::Visitor(3)

Extensible Markup Language (XML) <http://www.w3c.org/XML>

Perl Diver brought to you by ScriptSolutions.com © 1997- 2026