1ExtUtils::Packlist(3) User Contributed Perl DocumentationExtUtils::Packlist(3)
2
3
4

NAME

6       ExtUtils::Packlist - manage .packlist files
7

SYNOPSIS

9          use ExtUtils::Packlist;
10          my ($pl) = ExtUtils::Packlist->new('.packlist');
11          $pl->read('/an/old/.packlist');
12          my @missing_files = $pl->validate();
13          $pl->write('/a/new/.packlist');
14
15          $pl->{'/some/file/name'}++;
16             or
17          $pl->{'/some/other/file/name'} = { type => 'file',
18                                             from => '/some/file' };
19

DESCRIPTION

21       ExtUtils::Packlist provides a standard way to manage .packlist files.
22       Functions are provided to read and write .packlist files.  The original
23       .packlist format is a simple list of absolute pathnames, one per line.
24       In addition, this package supports an extended format, where as well as
25       a filename each line may contain a list of attributes in the form of a
26       space separated list of key=value pairs.  This is used by the
27       installperl script to differentiate between files and links, for
28       example.
29

USAGE

31       The hash reference returned by the new() function can be used to
32       examine and modify the contents of the .packlist.  Items may be
33       added/deleted from the .packlist by modifying the hash.  If the value
34       associated with a hash key is a scalar, the entry written to the
35       .packlist by any subsequent write() will be a simple filename.  If the
36       value is a hash, the entry written will be the filename followed by the
37       key=value pairs from the hash.  Reading back the .packlist will
38       recreate the original entries.
39

FUNCTIONS

41       new()
42           This takes an optional parameter, the name of a .packlist.  If the
43           file exists, it will be opened and the contents of the file will be
44           read.  The new() method returns a reference to a hash.  This hash
45           holds an entry for each line in the .packlist.  In the case of old-
46           style .packlists, the value associated with each key is undef.  In
47           the case of new-style .packlists, the value associated with each
48           key is a hash containing the key=value pairs following the filename
49           in the .packlist.
50
51       read()
52           This takes an optional parameter, the name of the .packlist to be
53           read.  If no file is specified, the .packlist specified to new()
54           will be read.  If the .packlist does not exist, Carp::croak will be
55           called.
56
57       write()
58           This takes an optional parameter, the name of the .packlist to be
59           written.  If no file is specified, the .packlist specified to new()
60           will be overwritten.
61
62       validate()
63           This checks that every file listed in the .packlist actually
64           exists.  If an argument which evaluates to true is given, any
65           missing files will be removed from the internal hash.  The return
66           value is a list of the missing files, which will be empty if they
67           all exist.
68
69       packlist_file()
70           This returns the name of the associated .packlist file
71

EXAMPLE

73       Here's "modrm", a little utility to cleanly remove an installed module.
74
75           #!/usr/local/bin/perl -w
76
77           use strict;
78           use IO::Dir;
79           use ExtUtils::Packlist;
80           use ExtUtils::Installed;
81
82           sub emptydir($) {
83               my ($dir) = @_;
84               my $dh = IO::Dir->new($dir) || return(0);
85               my @count = $dh->read();
86               $dh->close();
87               return(@count == 2 ? 1 : 0);
88           }
89
90           # Find all the installed packages
91           print("Finding all installed modules...\n");
92           my $installed = ExtUtils::Installed->new();
93
94           foreach my $module (grep(!/^Perl$/, $installed->modules())) {
95              my $version = $installed->version($module) || "???";
96              print("Found module $module Version $version\n");
97              print("Do you want to delete $module? [n] ");
98              my $r = <STDIN>; chomp($r);
99              if ($r && $r =~ /^y/i) {
100                 # Remove all the files
101                 foreach my $file (sort($installed->files($module))) {
102                    print("rm $file\n");
103                    unlink($file);
104                 }
105                 my $pf = $installed->packlist($module)->packlist_file();
106                 print("rm $pf\n");
107                 unlink($pf);
108                 foreach my $dir (sort($installed->directory_tree($module))) {
109                    if (emptydir($dir)) {
110                       print("rmdir $dir\n");
111                       rmdir($dir);
112                    }
113                 }
114              }
115           }
116

AUTHOR

118       Alan Burlison <Alan.Burlison@uk.sun.com>
119
120
121
122perl v5.26.3                      2017-05-28             ExtUtils::Packlist(3)
Impressum