Dano Utilities Readme

Installation and usage guide for Dano - a collection of miscellaneous Perl utilities and helper functions for CGI programming

Perl Utility Library Documentation

Table of Contents

Overview

Dano is a collection of miscellaneous Perl utilities and helper functions designed to simplify common CGI programming tasks. Unlike standalone scripts like FormMail or Guestbook, Dano is a library meant to be included in your own Perl scripts.

The utilities include functions for:

  • Form data parsing and validation
  • Environment variable handling
  • File I/O with proper locking mechanisms
  • Data formatting and display
  • Security and input sanitization
  • Date and time formatting
  • HTML output helpers

Installation

Step 1: Upload Files

Upload the dano.pl file to your server. You have two common options:

Location Option 1 Place in your cgi-bin directory: /cgi-bin/lib/dano.pl
Location Option 2 Place in a shared library directory: /home/username/lib/dano.pl
Permissions chmod 644 dano.pl (readable by all)

Step 2: Configure Perl Path

Edit the first line of dano.pl to match your server's Perl location:

#!/usr/bin/perl

Common Perl paths:

  • #!/usr/bin/perl
  • #!/usr/local/bin/perl
  • #!/usr/bin/perl5

Step 3: Test the Library

Create a simple test script to verify the library loads correctly:

#!/usr/bin/perl

# Include the Dano library
require "/path/to/dano.pl";

print "Content-type: text/html\n\n";
print "<h1>Dano Library Test</h1>";
print "<p>If you see this, Dano loaded successfully!</p>";

Basic Usage

Including Dano in Your Scripts

Add this line near the top of your Perl CGI script:

#!/usr/bin/perl

require "/path/to/dano.pl";

# Your script code here...
Path Notes:
  • Use absolute paths: require "/home/username/lib/dano.pl";
  • Or relative to cgi-bin: require "./lib/dano.pl";
  • Make sure the path is readable by the web server

Available Functions

Once you've included Dano, you have access to various utility functions. Here are some common ones:

Parses form data from both GET and POST methods into a hash.

&parse_form;
my $name = $in{'name'};
my $email = $in{'email'};

Provides safe file locking for concurrent access.

&file_lock("$datafile");
# Read/write file safely
&file_unlock("$datafile");

Encodes special characters to prevent HTML injection.

$safe_text = &html_encode($user_input);

Returns formatted date and time strings.

$date = &get_date();
# Returns: "Tuesday, December 17, 2025"

Code Examples

Complete CGI Script Using Dano

#!/usr/bin/perl

require "/home/username/lib/dano.pl";

# Parse incoming form data
&parse_form;

# Print HTTP header
print "Content-type: text/html\n\n";

# Print HTML with safe encoding
print "<html><head><title>Form Results</title></head><body>";
print "<h1>Thank You!</h1>";
print "<p>Name: " . &html_encode($in{'name'}) . "</p>";
print "<p>Date: " . &get_date() . "</p>";
print "</body></html>";

File Handling Example

#!/usr/bin/perl

require "/home/username/lib/dano.pl";

$datafile = "/home/username/data/entries.txt";

# Lock file for safe writing
&file_lock($datafile);

open(FILE, ">>$datafile");
print FILE "New entry: " . &get_date() . "\n";
close(FILE);

# Unlock file
&file_unlock($datafile);

Troubleshooting

Common Issues

Error: "Can't locate dano.pl"

Solution: Check the path in your require statement. Use absolute paths:

require "/home/username/lib/dano.pl";

Error: "500 Internal Server Error"

Possible Causes:

  • Wrong Perl path in shebang line
  • Incorrect file permissions
  • Syntax errors in your script

Solution: Check error logs and verify permissions with chmod 755 for scripts.

Functions Not Working

Solution: Make sure you're calling functions with & prefix:

&parse_form();  # Correct
parse_form();   # May not work

Related Documentation

Dano Examples

Real-world code examples using Dano utilities

FormMail Readme

Installation guide for the FormMail script

All Readme Files

Browse all script documentation