Listing 1: First Version of Apache::TagNew

package Apache::TagNew;
use strict;
use Apache::Constants qw(OK DECLINED NOT_FOUND);
sub handler {
    # Get the Apache request object
    my $r = shift;
    # Only handle text/html files
    return DECLINED unless ($r->content_type
    eq "text/html");
    # Get the file we're trying to send
    if (open(FILE, $r->filename))
    {
   # Send an appropriate MIME header
   $r->send_http_header;
   # Slurp up files at once
   undef $/;
        # Grab the file's contents
   my ($contents) = (<FILE>);
   # Tag hyperlinks as new
   $contents =~ s|</a>|</a><font
   color="red">(New!)</font>|igs;
   # Print the contents
   $r->print($contents);
        # Close the file handle
   close FILE;
   # Indicate that all went well
        return OK;
    }
    # produce an appropriate error message
    else
    {
        return NOT_FOUND;
    }
}

1;