NAME

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

SYNOPSIS

use PPM::Make 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;
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);
which

Find the full path to a program, if available.

my $perl = which('perl');
parse_ppd

Parse a ppd file.

my $ppd = 'package.ppd';
my $d = parse_ppd($ppd);
print $d->{ABSTRACT};
print $d->{OS}->{NAME};
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');

Uses a remote soap server or CPAN.pm to perform a module search.

my $mod = 'Net::FTP';
my $results = mod_search($mod);

The query term must match exactly, in a case sensitive manner. The results are returned as a hash reference of the form

print <<"END";
  Module: $results->{mod_name}
  Version: $results->{mod_vers}
  Description: $results->{mod_abs}
  Author: $results->{author}
  CPAN file: $results->{dist_file}
  Distribution: $results->{dist_name}
END

Not all fields are guaranteed to have a value.

If an array reference is passed to mod_search containing a list of modules to be queried, a corresponding hash reference is returned, the keys being the query terms and the values being a hash reference as above.

Uses a remote soap server or CPAN.pm to perform a distribution search.

my $dist = 'libnet';
my $results = dist_search($dist);

The query term must match exactly, in a case sensitive manner. The results are returned as a hash reference of the form

print <<"END";
  Distribution: $results->{dist_name}
  Version: $results->{dist_vers}
  Description: $results->{dist_abs}
  Author: $results->{author}
  CPAN file: $results->{dist_file}
END

Not all fields are guaranteed to have a value.

If an array reference is passed to dist_search with a list of distributions to be queried, a corresponding hash reference is returned, the keys being the query terms and the values being a hash reference as above.

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.

fetch_file

Fetches a file, and if successful, returns the stored filename. If the file is specified beginning with http:// or ftp://:

my $fetch = 'http://my.server/my_file.tar.gz';
my $filename = fetch_file($file);

will grab this file directly. Otherwise, if the file has an extension \.(tar\.gz|tgz|tar\.Z|zip), if the file exists locally, it will use that; otherwise, it will assume this is a CPAN distribution and grab it from a CPAN mirror:

my $dist = 'A/AB/ABC/file.tar.gz';
my $filename = fetch_file($dist);

which assumes the file lives under $CPAN/authors/id/. If neither of the above are satisfied, it will assume this is a module name, and fetch the corresponding CPAN distribution, if found.

my $mod = 'Net::FTP';
my $filename = fetch_file($mod);
url_list

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

my @list = url_list();
fetch_nmake

Fetch nmake.exe.

unless (my $installed_nmake = fetch_nmake) {
    print "I could not retrieve nmake";
}

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.