my $adminpassword = "test"; my %cookie; if ( !exists $cookie{'pass'} ) { if ( param() ) { my $adminpass = param('admin'); if ( $adminpass eq $adminpassword ) { my $cookiename = cookie( -name => 'cookie', -value => 'loggedin', -expires => '+1h' ); print header, start_html(); # print rest of page here print "you are logged in"; } } else { print header, start_html(); print "Incorrect password, please click back and try again"; exit; } } else { print header, start_html(); print start_form(), table( Tr( td("Admin Password: "), td( textfield( -name => 'admin', -size => 10 ) ) ), Tr( td(), td(submit) ), ), end_form(), hr(); } }