#!/usr/bin/perl use Net::LDAP; @hosts =qw[ host1 host2 host3]; sub Check { foreach (@hosts) { $ldap = Net::LDAP->new( "$_" ) or die "$@"; } }