Class::STAF - Simplify version for the Perl STAF API


    use Class::STAF;
    my $handle = Class::STAF->new("My Program")
        or die "Error: can not create handle. RC=$!";
    my $result = $handle->submit("local", "PING", "PING")
        or print "submit failed ($!): ", $handle->LastError, "\n";
    $service = $handle->host("local")->service("PING");
    $result = $service->submit("PING");


This module is an alternative API for STAF - More Perlish.

For more info about STAF:

Instead of checking for every request that the return code is zero, and only then proceed, this API return the answer immidiatly. Only if the return code is not zero, the submit will return undef. Then the return code is saved in $!, and the error message can be retrived using $handle->LastError command.

Also export by default the Marshall and UnMarshall functions from Class::STAF::Marshalled, and will export by request the get_staf_fields and get_staf_class_name.

The Class::STAF object

The functions are similar to the original STAF API. Creating:

    my $handle = Class::STAF->new("My Program")
        or die "Error: can not create handle. RC=$!";

The new function only return a return code.

Member functions:


Will automatically un-register the STAF handle on destroy.

Creating Host and Service objects

    my $host = $handle->host("local");

will create an object to communicate with the local computer. usefull when you make repeating request to the same computer. And using it is similar to how we use the handle object, minus the host parameter:

    my $result = $host->submit("PING", "PING") or die "Oops\n";

Also, we can create a service object:

    my $service = $host->service("PING");

And use it:

    $service->submit("PING") or die "Ping is not working on that host?!";

Thread Safety

This module is thread safe by itself, but it is based on PLSTAF. It is still not clear wether the PLSTAF module is thread safe or not.

Also, this warpper will automatically unregister the STAF Handle only after it is released from all the threads that use it.

As result of this thread safety, this module support Perl 5.6.1 and up.


Non known.

This is a first release - your feedback will be appreciated.


STAF homepage:

The STAFService CPAN module.

Object Marshalling API: Class::STAF::Marshalled


Fomberg Shmuel, <>


Copyright 2008 by Shmuel Fomberg.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.