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


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


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


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

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

Loads a CHECKSUMS file into $cksum (adapted from the MD5 check of

  my $cksum = load_cs('CHECKSUMS');

Verify a CHECKSUM for a $file

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

Verify a CHECKSUM for a $file

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

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;

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;

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);

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);

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 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:


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.


Returns the source and build directories used with, 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;

Extracts a version string from a module file.

  my $version = parse_version('C:/Perl/lib/');

Attempt to obtain an abstract from a module file.

  my $package = 'CPAN';
  my $file = 'C:/Perl/lib/';
  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);

Gets a list of CPAN mirrors, incorporating any from

  my @list = url_list();

Gets a file from a remote source and store it to a local file.

  my $success = getstore($url, $file);

Encodes non-ascii characters.

  my $encoded = encode_non_ascii_chars($non_ascii_string);


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