use strict;
# This is public domain code. Do whatever you want with it.
# patch distribution as sample code for converting accounts from
# ldif format (as used by Netscape web servers) to Apache password format.
my $uid='';
my $passwd='';
while (my $line = <>) {
chomp $line;
if ( $line =~ /userpassword:\s*(\{\w+\}.+)/) {
$passwd = $1;
$passwd =~ s/^\{crypt\}//i; # Apache stores crypt without a magic string
}
if (length($line)==0) {
} # output if we have something to print
$uid = '';
$passwd = '';
} # if newline
} # while something to read
# handle last entry if there isn't a newline before EOF
}