Listing 1. User Identification Program
#!/usr/bin/perl
use strict;
use diagnostics;
use CGI; # Available from http://www.perl.com/CPAN
# Create an instance of CGI
my $query = new CGI;
# Print a basic MIME type
print $query->header("text/html");
# Retrieve the user's name
my $username = $query->remote_user;
# Print some output
print $query->start_html(-title => "You are...");
print "<H1>You are...</H1>\n";
if ($username)
{
print "<P>$username</P>\n";
}
else
{
print "<P>unidentified!</P>\n";
}
print $query``->end_html;
Copyright © 1994 - 2019 Linux Journal. All rights reserved.