#!/usr/local/bin/perl -w use strict; my @attr_list = qw/ cn fonDeptName telephoneNumber l st fonManagerDN=cn /; # did you open the file? open LDAPFILE, ">ldap" or die "Can not create ldap"; # print column header print LDAPFILE "InputValue:", join(':', @attr_list), "\n"; close LDAPFILE; # ... # Set up a search pattern that will recognize any attribute. my $attrs = join '|', @attr_list; # <-- you probably want | instead of : ? # Create a hash with attribute names as search keys my %attrs = map { $_ => '' } @attr_list; # ... # ...