The API provides function calls for accessing all the low-level facilities of Domain Managers. Each of these primitives can be invoked with reference to the InCharge::session handle, described in step 1 on page 19, and takes arguments that exactly match the API syntax.
The API also provides an object-oriented abstraction layer that allows Perl code to access the Domain Manager, by using a syntax that is very similar to ASL. For example, in ASL you can list the vendors of all routers, by using this logic:
routers = getInstances( "Router" ); foreach router ( routers ) { obj = object( "Router", router ); vendor = obj->Vendor; print( router . " - " . vendor ); }
When using the Perl API to perform the same action, the code looks like this:
@routers = $session->getInstances( "Router" ); foreach $router ( @routers ) { $obj = $session->object( "Router", $router ); $vendor = $obj->{Vendor}; print $router . " - " . $vendor . "\n”; }
The two code fragments in the ASL and Perl API example are very similar. The first main difference is a matter of syntax. Perl uses ``$'' and ``@'' to denote scalar and array variables, and {..} to denote object properties, which are hash table lookups. The second difference is that the object( .. ) and getInstances( .. ) functions are called with reference to a session handle in the Perl code.