my $PASSFILE="/pathto/file/.htpasswd"; open(WRT,">$PASSFILE"); my $id_password; # this is where I pull the list of id's # and passwords from a database or file, # then populate $id_password->{id}=pass; $id_password->{'richard'} = "mypass"; foreach my $id (keys %{$id_password}){ my $pass = $id_password->{$id}; my $pass2 = crypt($pass, "Ce"); print WRT "$id:$pass2\n"; } close(WRT);