Class P4::Spec

Description

P4::Spec objects provide easy access to the attributes of the fields in a P4 Server form.

The P4::Spec class uses Perl’s AutoLoader to simplify form manipulation. Form fields can be accessed by calling a method with the same name as the field prefixed by an underscore (_).

Custom specifications require that you call Fetch first so that the specDefs can be determined by the API and later used by ParseSpec.

As a best practice, always call FetchSpec before ParseSpec. This ensures that P4 API for Perl uses the current specification definition from the P4 Server and helps prevent parsing errors that can occur when newer server releases add fields that are not recognized by older P4 API for Perl versions.

Class Methods

$spec = new P4::Spec( $fieldMap ) -> array

Constructs a new P4::Spec object for a form containing the specified fields. (The object also contains a fields member that stores a list of field names that are valid in forms of this type.)

Instance Methods

$spec->_<fieldname> -> string

Returns the value associated with the field named <fieldname>.

$client = $p4->FetchClient( $clientname );
$client->_Root();    # Get client root

$spec->_<fieldname>( $string )-> string

Updates the value of the named field in the spec.

$client = $p4->FetchClient( $clientname );
$client->_Root( $newroot );    # Set client root

$spec->PermittedFields() -> array

Returns an array containing the names of fields that are valid in this spec object. This does not imply that values for all of these fields are actually set in this object, merely that you may choose to set values for any of these fields if you want to.

my $client = $p4->FetchClient( $clientname );
my @permitted = $client->PermittedFields();
foreach $field (@permitted) {
print "$field\n";
}