in reply to elsif ne loop

From `man 3 crypt:

"salt  is  a  two-character string chosen from the set [a-zA-Z0-9./]."
You will be greatly helped debugging this by use diagnostics; and use strict;. Your code appears to be based either on all global variables, or else you have a closure with probably unintended effects.

All those global-looking things make this impossible to debug in isolation. The whole script needs to be debugged as a unit. It would be a good idea to pass the CGI object and other data to it as parameters.

After Compline,
Zaxo