Password Scripts

Can anyone offer any advice on password scripts and how they work?

I want to password specific folders on my site so I can upload files into a folder and it will only be accessible with the correct username / password. I’d then give user’s details to access this folder.

Also if possible depending on the username / password entered, users would only be able to see or access certain files.

I have CGI/Perl Script enabled on my web space.

Can anyone point me in the right direction?