This example is based on the code in the library_crud.pl sample file.

For more information about storing the contents of a local library, see Content Library Storage.

Note: For a complete and up-to-date version of the sample code, see the vSphere Automation SDK Perl samples at GitHub.
...

# Create a StorageBacking instance of datastore type.
my $library_backing = new
   Com::Vmware::Content::Library::StorageBacking();
$library_backing->set_type('type' =>
   Com::Vmware::Content::Library::StorageBacking::Type::DATASTORE);

# Pass the value of the datastore managed object reference.
$library_backing->set_datastore_id('datastore_id' => 'datastore-123');
my $library_model = new
   Com::Vmware::Content::LibraryModel();
$library_model->set_name('name' => 'AcmeLibrary');
$library_model->set_storage_backings('storage_backings' => [$library_backing]);

...