my last question was about how to implement basic authentication in perl and i got my answer.
after that i tried to write my code.i used -status => '401 Not Authorized' in my http header and when i try to open my programm it wants me to enter user and password.in my code i got peice of header with ENV variable that include this username and password and check if it was what i want.my problem is that when i enter user and password in authentication box like below 
i should click on cancel button to get response header!!so what is ok button here? its my verification code
print header(-type => 'text/html', -status => '401 Not Authorized',
'WWW-Authenticate' => 'Basic realm="Videos"');
print "<HTML>";
print "<HEAD>";
print "<TITLE>this is Test-Case</TITLE>";
print "</HEAD>";
my $signin = $ENV{HTTP_AUTHORIZATION};
my($basic,$userpass) = split( ' ', $signin );
($userpass,$eq) = split( '=',$userpass );
$userpass = decode_base64($userpass);
my ($user,$pass) = split( ':',$userpass );
my $query = new CGI;
if($user eq 'aa' and $pass eq 'aa'){
show something
}
else{
print "wrong user or pass";
}
i tried to use CGI::Auth::Basic before but it doesnt work for me and show error in module.
Thanks for your answers.
i solved my problem after a while so i decided to tell the answer for who have this problem too. you should firs check if $ENV{HTTP_AUTHORIZATION} is defined or not.if its defined you should check the user pass and if its true you print "Content-Type: text/HTML", "\n\n" that means 200ok!and if the ENV not defined you should print print header(-type => 'text/html', -status => '401 Not Authorized','WWW-Authenticate' => 'Basic realm="Videos"') to show the authentication box.
$signin = $ENV{HTTP_AUTHORIZATION};
if(defined $signin){
check user and password here
if(true user and password){
print "Content-Type: text/HTML", "\n\n";
do your all works here
}
else{
wrong password
}
}
else{
print header(-type => 'text/html', -status => '401 Not Authorized','WWW-Authenticate' => 'Basic realm="Videos"');
}
$signin, $basic, $userpass, $user, $pass) to see if everything is as you thought it would be?