use Digest::MD5 qw(md5 md5_hex md5_base64);
my $encrpass = md5($password); # binary
or
my $encrpass = md5_hex($password); # human-readable
or
my $encrpass = md5_base64($password); # human-readable too
That doesn't do what you want. Have a look at the reply from fokat below; it has the/a correct answer. Also, if your libc's crypt supports MD5 passwords natively, all you have to do is generate an appropriate salt; see this node for more info.