In your Perl development, it’s quite likely that you will
encounter files in different formats — XML, PDF, CSV, RSS
— and different binary data formats. Your Perl application may need to
manipulate these files, either reading from them or writing to them.

You can simplify this task by turning to the Comprehensive
Perl Archive Network (CPAN),
which has a huge number of Perl
modules designed specifically to deal with different file formats. This
document lists ten such modules of specific interest to developers who need to
work with custom file formats.

Note: You can
install CPAN modules directly from the Internet, by following the instructions
provided at http://www.cpan.org/misc/cpan-faq.html#How_install_Perl_modules

Table A

Package Name

Description

DBI

This module provides a database-independent wrapper to
allow Perl to communicate with a database. It supports database connection
and management, query execution, transactions and stored procedures, and
error handling. A wide variety of databases, including MySQL, PostgreSQL and
Oracle, are supported via add-on database drivers (DBDs).

Use this
package when you need to retrieve data from an RDBMS

Archive::Tar 

This module lets you read and write TAR archives through a
simple object-oriented interface. It allows you to package multiple files
into a single TAR file, list the contents of a TAR archive, and selectively
extract from (or import into) a TAR file. It may also be used with GZIP
compressed files.

Use this
package when you need to create or extract files from TAR or GZ archives.

Archive::Zip

This module makes it possible for a Perl program to read
and write ZIP archive files. The module provides OOP methods to create and
read ZIP archives, add files to them, alter existing archive contents
(including altering dates and names), extract archive contents or query file
information.

Use this
package when you need to create or extract files from ZIP archives.

Class::CSV

This module provides an object-based framework to efficiently
deal with comma-separated data. It allows CSV files to be represented as
objects (and vice-versa), making it possible to easily read comma-separated
values into Perl variables. It also includes methods to write new CSV records
to a file using custom patterns and separators.

Use this
package when you need to work with files containing comma-delimited data
fields.

Unix::PasswdFile

This module provides an object-oriented interface to
manipulate different types of password files. It includes methods to add,
edit and delete users and passwords, validate passwords, and generate
passwords. It can also be used to manipulate other fields of a password file,
including home directory and shell configuration and the GECOS string.

Use this
package when you need to manipulate UNIX password files, to verify passwords,
and to easily add/edit/delete user accounts and configuration.

PDF::API2

This module lets you generate a new PDF file, or
manipulate an existing one. It allows you to add new pages, set fonts and
font attributes for text, insert images and work with colors. It also
includes methods to import forms, export PDF data as a string, and set or
alter PDF document information.

Use this
package when you need to generate PDF files on the fly, or retrieve metadata
information from existing PDF files.

XML::RSS

This module is designed to create and maintain RSS feeds.
It provides an object-oriented framework to query an RSS feed, retrieve
headlines and stories, and convert RSS data into HTML pages suitable for
browser display.

Use this
package when you need to extract information from an (or create a new) RSS
feed.

Win32::Word::Writer

This module lets you create new Microsoft Word documents
(Win32 Perl only; requires Microsoft Word). It allows you to set fonts and
colors, format text using different styles, create bulleted lists and
generate tables.

Use this
package when you need to generate Microsoft Word files dynamically.

 

MP3::Tag

This module is a wrapper around several different MP3 tag
readers. It provides routines to view and edit the metadata information
stored in MP3 file headers (“tags”). It supports reading and
changing common fields like artist, title, track length, genre and duration,
or creating new custom fields.

Use this
package to create new MP3 audio file tags, or read and alter existing tags.

Net::vCard

This module parses and converts contact information stored
in vCard format to Perl data structures.

Use this
package when you need to convert vCard address and contact information into
other formats (for example, XML or SQL).