in reply to Re^3: Peculiar problem with Net::LDAPS and AD LDAP
in thread Peculiar problem with Net::LDAPS and AD LDAP

Assuming that you need to change 'ABCD' into '\AB\CD', there should be an easier way:

sub enc_hex { my $out = unpack('H*', (shift)); $out =~ s/\G(..)/\\$1/g; return $out; }

This uses the regex engine to advance through the string two characters at a time, inserting backslashes before each pair in the output. See perlre and perlop for more details.