The NIS interface comes in two parts. The first part is the raw implementation of the NIS API, described
in Net::NIS. The second is the object interface. This document describes the object interface
implementation.
The Table object represents an individual NIS map. A NIS map is bound to a Table object with the new
method:
$obj = Net::NIS::Table->new($map, [ $domain ]);
For example,
$hostsmap = Net::NIS::Table->new("hosts.byname");
This will create a Table object bound to the "hosts.byname" NIS map in the default NIS domain. All
operations on the $hostsmap object will relate to the "hosts.byname" map.
You can also specify a non-default domain:
$hostsmap = Net::NIS::Table->new("hosts.byname", "my.domain.com.au");
Once a Table object has been bound to a NIS map, the following methods are available:
$value = $obj->match($key)
Returns the value for a given key. If you only wish to look up one or two values, this function is
more efficient, as it retrieves the items one at a time. If you wish to retrieve many items (where
many is dependent on the size of the map, and probably what sort of machine you are on), it is
better to use the list interface, which uses just one RPC call to retrieve the entire map.
\%data = $obj->list()
Return a reference to an associative array which contains the entire NIS map. The keys in the %data
array correspond to the keys in the NIS map. If any error occurs that prevents the retrieval of the
map, then the undefined value is returned. In this case, your program can use the status method to
determine the cause of the error.
\%data = $obj->search($srchkey)
Return a reference to an associative array which contains all entries that have keys that contain
the $srchkey. If any error occurs that prevents the retrieval of the map, then the undefined value
is returned. In this case, your program can use the status method to determine the cause of the
error.
$status = $obj->status()
Returns the status code for the last operation. If the last operation succeeded, then the status
code is 0. The status codes returned by this method are described below in the ERROR CODES section.
$status = $obj->status_string()
Returns the character representation of the status code for the last operation. If the last
operation succeeded, then the status code is something like "operation succeeded". The exact
strings returned by this function are implementation dependent, and should not be used for
comparison purposes. Use the status call, as described above.