Perl CGI Helper Scripts & Web Development Tools
Dano is a collection of miscellaneous Perl utilities and helper functions designed to simplify common CGI programming tasks. These modular tools were created to work alongside the main script archive, providing reusable functionality for form processing, data validation, file handling, and more.
Dano is a collection of miscellaneous Perl utilities that were developed to support CGI script development in the 1990s. Rather than being a single application, it's a toolkit of reusable subroutines and helper scripts that address common web development needs.
The collection includes utilities for:
require or do.
Parse GET and POST form data into associative arrays. Handles URL encoding and multipart forms.
%FORM = &parse_form();
Clean and validate user input to prevent injection attacks and data corruption.
$safe = &sanitize($input);
Safe file operations with proper locking to prevent data corruption from concurrent access.
&lock_file($fh);
Format dates and times in various styles for display in web pages.
$date = &format_date($time);
Basic email address format validation using regular expressions.
if (&valid_email($addr)) { }
Escape HTML entities to safely display user-submitted content.
$safe_html = &html_escape($text);
In the mid-1990s, web developers didn't have modern frameworks, package managers, or standard libraries. CGI scripts were often written from scratch, and common tasks like form parsing had to be reimplemented repeatedly.
"Before CPAN became widely adopted, CGI script archives provided not just complete applications, but also reusable utility libraries that developers could include in their own projects."
| 1993 | CGI specification introduced |
| 1995 | Perl becomes dominant CGI language |
| 1995-1999 | Golden era of CGI script archives |
| 1995 | CGI.pm released by Lincoln Stein |
| 1999 | mod_perl gains popularity |
| 2000+ | PHP begins to dominate web scripting |
The original CGI.pm module by Lincoln Stein became so popular it was eventually included in Perl's core distribution.
In 1996, CPAN (Comprehensive Perl Archive Network) had only about 500 modules. Today it has over 200,000.
Many concepts from early CGI libraries live on in modern frameworks.
#!/usr/bin/perl
# Include the Dano library
require "dano.lib";
# Parse form data
%FORM = &parse_form();
# Validate email
if (!&valid_email($FORM{'email'})) {
&error("Invalid email address");
}
# Sanitize input for display
$safe_name = &html_escape($FORM{'name'});
# Format current date
$today = &format_date(time);
# Lock file for writing
open(DATA, ">>data.txt");
&lock_file(DATA);
print DATA "$safe_name|$FORM{'email'}|$today\n";
&unlock_file(DATA);
close(DATA);
# Output HTML
print "Content-type: text/html\n\n";
print "<html><body>";
print "<p>Thank you, $safe_name!</p>";
print "<p>Submitted on: $today</p>";
print "</body></html>";
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use Email::Valid;
use HTML::Entities;
use Fcntl qw(:flock);
use POSIX qw(strftime);
my $cgi = CGI->new;
# Parse form data (CGI.pm handles this automatically)
my $email = $cgi->param('email') // '';
my $name = $cgi->param('name') // '';
# Validate email (using Email::Valid from CPAN)
unless (Email::Valid->address($email)) {
print $cgi->header('text/html');
print "<html><body>Invalid email address</body></html>";
exit;
}
# Sanitize input (using HTML::Entities)
my $safe_name = encode_entities($name);
# Format date (using POSIX)
my $today = strftime("%B %d, %Y", localtime);
# Lock and write file (using Fcntl)
open(my $fh, '>>', 'data.txt') or die "Cannot open: $!";
flock($fh, LOCK_EX);
print $fh "$safe_name|$email|$today\n";
close($fh);
# Output
print $cgi->header('text/html');
print "<html><body>";
print "<p>Thank you, $safe_name!</p>";
print "<p>Submitted on: $today</p>";
print "</body></html>";
<?php
/**
* PHP equivalent of Dano utility functions
*/
// Form parsing (built into PHP via $_POST, $_GET)
$email = $_POST['email'] ?? '';
$name = $_POST['name'] ?? '';
// Email validation (built-in filter)
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
die('Invalid email address');
}
// HTML escape (built-in function)
$safe_name = htmlspecialchars($name, ENT_QUOTES, 'UTF-8');
// Date formatting (built-in function)
$today = date('F j, Y');
// File writing with lock (built-in)
$fp = fopen('data.txt', 'a');
if (flock($fp, LOCK_EX)) {
fwrite($fp, "$safe_name|$email|$today\n");
flock($fp, LOCK_UN);
}
fclose($fp);
// Output
echo "<html><body>";
echo "<p>Thank you, $safe_name!</p>";
echo "<p>Submitted on: $today</p>";
echo "</body></html>";
?>
Today's Perl developers have access to a rich ecosystem of tested, maintained modules on CPAN. Modern web frameworks also provide these utilities out of the box:
The classic CGI handling module. Form parsing, headers, and HTML generation.
Email address validation with DNS checks.
Encode and decode HTML entities safely.
Flexible form data validation framework.
Modern real-time web framework. Batteries included with templates, WebSockets, and more.
Lightweight, minimalist web framework inspired by Sinatra.
Enterprise-grade MVC framework with extensive plugin ecosystem.
Modern interface between Perl web applications and web servers.
| Task | Dano (1990s) | Modern Perl (2024) |
|---|---|---|
| Form Parsing | &parse_form() |
CGI->new->param() or framework |
| Email Validation | &valid_email() |
Email::Valid->address() |
| HTML Escaping | &html_escape() |
HTML::Entities::encode_entities() |
| File Locking | &lock_file() |
flock($fh, LOCK_EX) |
| Date Formatting | &format_date() |
POSIX::strftime() or DateTime |
Main library file with all utility subroutines
Documentation and usage instructions
Example script demonstrating library usage