example shows how to find an item using the item name and then shows how to change the name and description of the retrieved item.

This example uses the steps that are described in the Edit the Settings of a Library Item procedure.

use Com::Vmware::Content;
use Com::Vmware::Content::Library::Item;

# 1 - List the items in a published library.
my $item_stub = new
   Com::Vmware::Content::Library::ItemService($my_stub_config);
my @item_ids = $item_stub->list($my_library_id);

# 2 - List the files uploaded to each library item
#     and print their names and sizes.
my $file_stub = new
   Com::Vmware::Content::Library::Item::File($my_stub_config);
foreach my $item_id (@item_ids) {
  my $item = $item_stub->get($item_id);
  my $item_name = $item->get_name();
  my @file_infos = $file_stub->list(item_id);
  foreach my $info (@file_infos) {
    my $info_name = $info->get_name();
    my $info_size = $info->get_size();
    print "Library item $item_name has file $info_name" .
         " with size $info_size";
  }

# 3 - For a library item with a specified name,
#     create an ItemModel to change the name and description of the item.
  if ($item_name == 'simpleVmTemplate' {
    my $item_description = $item->get_description();
    print "Library item '$item_name' with description" . 
         " '$item.description$'";
    my $item_model = new
       Com::Vmware::Content::Library::ItemModel();
    my $new_name = 'newItemName';
    my $new_description = 'Description of the newItemName';
    $item_model->set_name($new_name);
    $item_model->set_description($new_description);
    $item_stub->update(library_item_id => $item_id,
                       update_spec => $item_model);
    print "\nhas been changed to:\n";
    print "Library item '$new_name' with description" .
         " '$new_description'";
  }  # if item.name

}  # foreach $item_id