LinuxCommandLibrary

pl2pm

Convert Perl library (.pl) files to modules (.pm)

SYNOPSIS

pl2pm filename.pl

PARAMETERS

filename.pl
    The name of the Perl library file to convert.

DESCRIPTION

pl2pm is a command-line utility designed to convert legacy Perl library files ('.pl' extension) into modern Perl module files ('.pm' extension). This conversion involves wrapping the code within the library file into a proper Perl module structure. It mainly adds the 'package' declaration, ensures the file ends with '1;', and changes the file extension from '.pl' to '.pm'. The aim is to promote better code organization, namespace management, and adherence to modern Perl best practices. This tool simplifies the process of upgrading older Perl codebases by automating the transformation of library files into reusable modules. The conversion process is generally straightforward and requires minimal intervention. pl2pm is part of the Perl distribution and is typically available on systems with Perl installed. Using modules improves modularity and helps prevent naming collisions, contributing to cleaner and more maintainable Perl code.

CAVEATS

pl2pm performs a basic transformation. Complex library files might require manual adjustments after conversion. It does not handle namespace resolution or dependency management beyond the basic module conversion. Any global variables and subroutines must be checked manually.

EXAMPLE

To convert a library file named 'mylib.pl' to a module file named 'mylib.pm', execute the following command:
pl2pm mylib.pl
This will create 'mylib.pm' containing the module version of the library and change its extension.

SEE ALSO

perl(1), perlmod(1)

Copied to clipboard