List Info

Thread: Deleting a User From a Group




Deleting a User From a Group
user name
2006-07-10 13:14:51
To All,
 
I am attempting to write a script to delete users from a group. The problem I am having is with using splice() to remove the an item from the 'Users' array in the group definition. When I call the following sub routine, passing in a user to delete and the name of the group. The group is truncated at the point in the user array were there users name was found. This does not follow the expected behavior of splice(). Is there something that I'm missing? Or is there a better way to do this?
 

sub deleteUserFromGroup {
    my ( $targetUser, $targetGroup ) = _;
 
    my $group = $p4->FetchGroup( $targetGroup );
 
    testPrintArrayRef( "Begin", $group->{ 'Users' } );
 
    my $index = 0;
   ; foreach $groupUser ( {$group->{ 'Users' }} )
    {
       ; if ( $groupUser eq $targetUser )
       ; {
     ;       splice( {$group->{ 'Users' }}, $index, $index );
   ;     }
     ;   $index++;
  ;  }
 
    testPrintArrayRef( "End", $group->{ 'Users' } );
#    $p4->SaveGroup( $group );
}
 
sub testPrintArrayRef
{
    my ( $testMessage, $testArrayRef ) = _;
 
    print "TEST[$testMessage]: Total = $#{$testArrayRef}";
&nbsp;   for( my $index = 0; $index < $#{$testArrayRef}; $index++ )
 &nbsp;  {
 &nbsp;   ; &nbsp; print " [$index]" . $testArrayRef->[$index];
&nbsp; &nbsp; }
 &nbsp;  print "\n";
}

 
Thanks.....
Scott Lavender | SCM Specialist | Visiprise | office: 770.619.4166 | www.visiprise.com
 

It is our company policy not to accept email of any data controlled by the International Traffic in Arms Regulations (ITAR). Please contact our Security Officer,&nbsp;Matt Reeves, for instructions and authorization to transmit such data.

 
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )