#! /usr/bin/env perl use strict; use warnings; use CGI qw( -nph ) ; my $cgi = CGI->new; if ( $cgi->param('logout') ) { print $cgi->header( -status => '401 Unauthorized', "WWW-Authenticate" => qq~Basic realm="foobar"~, ), $cgi->start_html, 'Goodbye', $cgi->end_html, ; } else { print $cgi->header( 'text/html' ), $cgi->start_html(), $cgi->h1("Success"), $cgi->a({href=>"?logout=1"}, 'logout'), $cgi->end_html, ; }