NAME

PPM::Make::Util - Utility functions for PPM::Make

SYNOPSIS

use PPM::Make::Util qw(:all);

DESCRIPTION

This module contains a number of utility functions used by PPM::Make.

fix_path

Ensures a path is a Unix-type path, with no spaces.

my $path = 'C:\Program Files\';
my $unix_version = fix_path($path);
load_cs

Loads a CHECKSUMS file into $cksum (adapted from the MD5 check of CPAN.pm)

my $cksum = load_cs('CHECKSUMS');
verifyMD5

Verify a CHECKSUM for a $file

my $ok = verifyMD5($cksum, $file);
print "$file checked out OK" if $ok;
xml_encode

Escapes &, >, <, and ", as well as high ASCII characters.

my $escaped = xml_encode('Five is > four');
is_core

Tests to see if a module is part of the core, based on whether or not the file is found within a site type of directory.

my $is_core = is_core('Net::FTP');
print "Net::FTP is a core module" if $is_core;
is_ap_core

Tests to see if a package is part of the ActivePerl core (at least for recent ActivePerl versions).

my $is_ap_core = is_ap_core('libwin32');
print "libwin32 is a core package" if $is_ap_core;
trim

Trims white space.

my $string = '    This is a sentence.   ';
my $trimmed = trim($string);
file_to_dist

In scalar context, returns a CPAN distribution name filename based on an input file A/AB/ABC/filename-1.23.tar.gz:

my $file = 'A/AB/ABC/defg-1.23.tar.gz';
my $dist = file_to_dist($file);

In a list context, returns both the distribution name filename and the version number 1.23:

my $file = 'A/AB/ABC/defg-1.23.tar.gz';
my ($dist, $version) = file_to_dist($cpan_file);
ppd2cpan_version

Converts a ppd-type of version string (eg, 1,23,0,0) into a ppd one of the form 1.23:

my $s = "1,23,0,0";
my $v = ppd2cpan_version($v);
cpan2ppd_version

Converts a cpan-type of version string (eg, 1.23) into a ppd one of the form 1,23,0,0:

my $v = 1.23;
my $s = cpan2ppd_version($v);
parse_ppd

Parse a ppd file or a string.

my $ppd = 'package.ppd';
my $d = parse_ppd($ppd);
print $d->{ABSTRACT};
print $d->{OS}->{NAME};

my $e = parse_ppd($ppd, 'MSWin32-x86-multi-thread');
print $e->{ABSTRACT};

This routine takes a required argument of a ppd file containing a .ppd extension or a string and, optionally, an ARCHITECTURE name to restrict the results to. It returns a data structure containing the information of the ppd file or string:

$d->{SOFTPKG}->{NAME}
$d->{SOFTPKG}->{VERSION}
$d->{TITLE}
$d->{AUTHOR}
$d->{ABSTRACT}
$d->{PROVIDE}
$d->{DEPENDENCY}
$d->{REQUIRE}
$d->{OS}->{NAME}
$d->{ARCHITECTURE}->{NAME}
$d->{CODEBASE}->{HREF}
$d->{INSTALL}->{EXEC}
$d->{INSTALL}->{SCRIPT}
$d->{INSTALL}->{HREF}

The PROVIDE, REQUIRE and DEPENDENDENCY tags are array references containing lists of, respectively, the prerequisites required and the modules supplied by the package, with keys of NAME and VERSION.

If there is more than one IMPLEMENTATION section in the ppd file, all the results except for the SOFTPKG elements and TITLE, AUTHOR, and ABSTRACT will be placed in a $d->{IMPLENTATION} array reference. If an optional second argument is passed to parse_ppd($file, $arch), this will filter out all implementation sections except for the specified ARCHITECTURE given by $arch.

src_and_build

Returns the source and build directories used with CPAN.pm, if present. If not, returns those used with PPM, if those are present. If neither of these are available, returns the system temp directory.

my ($src_dir, $build_dir)= src_and_build;
tempfile

Generates the name of a random temporary file.

my $tmpfile = tempfile;
parse_version

Extracts a version string from a module file.

my $version = parse_version('C:/Perl/lib/CPAN.pm');
parse_abstract

Attempt to obtain an abstract from a module file.

my $package = 'CPAN';
my $file = 'C:/Perl/lib/CPAN.pm';
my $abstract = parse_abstract($package, $file);
cpan_file {

Given a file of the form file.tar.gz and a CPAN id of the form <ABCDEFG>, will return the CPAN file A/AB/ABCDEFG/file.tar.gz.

my $cpanid = 'GBARR';
my $file = 'libnet-1.23.tar.gz';
my $cpan_file = cpan_file($cpanid, $file);
url_list

Gets a list of CPAN mirrors, incorporating any from CPAN.pm.

my @list = url_list();

COPYRIGHT

This program is copyright, 2003, 2006 by Randy Kobes <r.kobes@uwinnipeg.ca>. It is distributed under the same terms as Perl itself.

SEE ALSO

PPM.