next up previous
Next: 5. Command line invocation Up: 6. What Perl looks Previous: 3. Regular expressions

4. Modules

Modules are freely available from CPAN, the Comprehensive Perl Archive Network. Here's how they're used:

# A simple example... URI::Escape provides a couple of handy functions
# for converting URLs to percent-encoded format:

use URI::Escape;

my $url = ""Fred Bloggs";
$encoded_url = uri_escape($url);
$original_url = uri_unescape($url);

# An object oriented example - fill in a text template

use Text::Template;

my $letter = new Text::Template(FILE, "letter.tmpl");
my $filled_letter = $letter->fill_in();
print $filled_letter;

Kirrily Robert