sub fetchData { my $selfObj=shift; my $ldapConn=shift; my $serviceFilter=shift; my $groupFilter=shift; my $parseFunction=shift; ... foreach my $group ($allGroups->entries) { print get_attribute($group,"erldapservicegroup")." "; my $response=&$parseFunction->($group); # $group is a Net::LDAP:Entry object and $parseFunction a reference on the function of the main script my $groupName=$response->{"name"}; $serviceDataObj->{"groups"}->{$groupName}=$groupName; } # foreach my $group ($allGroups->entries) } # sub fetchData