SNMP::Class::ResultSet - A list of SNMP::Class::Varbind objects.
Version 0.12
use SNMP::Class::ResultSet; my $foo = SNMP::Class::ResultSet->new; $foo->push($vb1); ... #later: ...
IMPORTANT NOTICE: All the methods that are returning a ResultSet will only do so when called in scalar context. They alternatively return the list of varbinds in list context.
Constructor. Just issue it without arguments. Creates an empty ResultSet. SNMP::Class::Varbind objects can later be stored in there using the push method.
In scalar context, this method returns the object itself, while in list context returns the list of the varbinds. In null context, it will croak. This method is mainly used for internal purposes.
Returns a reference to a list containing all the stored varbinds. Modifying the list alters the object.
Returns a string representation of the entire ResultSet. Mainly used for debugging purposes.
Takes one argument, which must be an SNMP::Class::Varbind or a descendant of that class. Inserts it into the ResultSet.
Pops a varbind out of the Set. Takes no arguments.
filter can be used when there is the need to filter the varbinds inside the resultset using arbitrary rules. Takes one argument, which is a reference to a subroutine which will be doing the filtering. The subroutine must return an appropriate true or false value just like in CORE::grep. The value of each SNMP::Class::Varbind item in the ResultSet gets assigned to the $_ global variable. For example:
print $rs->filter(sub {$_->get_label_oid == 'sysName'});
If used in a scalar context, a reference to a new ResultSet containing the filter results will be returned. If used in a list context, a simple array containing the varbinds of the result will be returned. Please do note that in the previous example, the print function always forces list context, so we get what we want.
Filters based on key-value pairs that are labels and values. For example:
$rs->find('ifDescr' => 'eth0', ifDescr => 'eth1');
will find which are the instance oids of the row that has ifDescr equal to 'eth0' or 'eth1' (if any), and filter using that instances.
This means that to get the ifSpeed of eth0, one can simply issue:
my $speed = $rs->find('ifDescr' => 'eth0')->ifSpeed->value;
Returns the number of items present inside the ResultSet
Reveals whether the ResultSet is empty or not.
The dot method overloads the '.' operator, returns SNMP::Class::Varbind. Use it to get a single SNMP::Class::Varbind out of a ResultSet as a final instance filter. For example, if $rs contains ifSpeed.1, ifSpeed.2 and ifSpeed.3, then this call:
$rs.3
returns the ifSpeed.3 SNMP::Class::Varbind.
Please note that this method does not return a ResultSet like the instance method, but a Varbind which should be the sole member of the ResultSet having that instance. If the ResultSet has more than one Varbinds with the requested instance and the dot operator is used, a warning will be issued, and only the first matching Varbind will be returned
Returns the item of the ResultSet with index same as the first argument. No argument yields the first item (index 0) in the ResultSet.
Athanasios Douitsis, <aduitsis at cpan.org>
<aduitsis at cpan.org>
Please report any bugs or feature requests to bug-snmp-class-resultset at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SNMP::Class. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-snmp-class-resultset at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc SNMP::Class
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/SNMP::Class
CPAN Ratings
http://cpanratings.perl.org/d/SNMP::Class
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=SNMP::Class
Search CPAN
http://search.cpan.org/dist/SNMP::Class
Copyright 2007 Athanasios Douitsis, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install SNMP::Class, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SNMP::Class
CPAN shell
perl -MCPAN -e shell install SNMP::Class
For more information on module installation, please visit the detailed CPAN module installation guide.