Install Perl 5.8.8
[msysgit.git] / mingw / html / lib / ExtUtils / Packlist.html
blobff44518f3f006bbf0241b2908301b774d12bf9d3
1 <?xml version="1.0" ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>ExtUtils::Packlist - manage .packlist files</title>
6 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7 <link rev="made" href="mailto:" />
8 </head>
10 <body style="background-color: white">
11 <table border="0" width="100%" cellspacing="0" cellpadding="3">
12 <tr><td class="block" style="background-color: #cccccc" valign="middle">
13 <big><strong><span class="block">&nbsp;ExtUtils::Packlist - manage .packlist files</span></strong></big>
14 </td></tr>
15 </table>
17 <p><a name="__index__"></a></p>
18 <!-- INDEX BEGIN -->
20 <ul>
22 <li><a href="#name">NAME</a></li>
23 <li><a href="#synopsis">SYNOPSIS</a></li>
24 <li><a href="#description">DESCRIPTION</a></li>
25 <li><a href="#usage">USAGE</a></li>
26 <li><a href="#functions">FUNCTIONS</a></li>
27 <li><a href="#example">EXAMPLE</a></li>
28 <li><a href="#author">AUTHOR</a></li>
29 </ul>
30 <!-- INDEX END -->
32 <hr />
33 <p>
34 </p>
35 <h1><a name="name">NAME</a></h1>
36 <p>ExtUtils::Packlist - manage .packlist files</p>
37 <p>
38 </p>
39 <hr />
40 <h1><a name="synopsis">SYNOPSIS</a></h1>
41 <pre>
42 use ExtUtils::Packlist;
43 my ($pl) = ExtUtils::Packlist-&gt;new('.packlist');
44 $pl-&gt;read('/an/old/.packlist');
45 my @missing_files = $pl-&gt;validate();
46 $pl-&gt;write('/a/new/.packlist');</pre>
47 <pre>
48 $pl-&gt;{'/some/file/name'}++;
50 $pl-&gt;{'/some/other/file/name'} = { type =&gt; 'file',
51 from =&gt; '/some/file' };</pre>
52 <p>
53 </p>
54 <hr />
55 <h1><a name="description">DESCRIPTION</a></h1>
56 <p>ExtUtils::Packlist provides a standard way to manage .packlist files.
57 Functions are provided to read and write .packlist files. The original
58 .packlist format is a simple list of absolute pathnames, one per line. In
59 addition, this package supports an extended format, where as well as a filename
60 each line may contain a list of attributes in the form of a space separated
61 list of key=value pairs. This is used by the installperl script to
62 differentiate between files and links, for example.</p>
63 <p>
64 </p>
65 <hr />
66 <h1><a name="usage">USAGE</a></h1>
67 <p>The hash reference returned by the <a href="#item_new"><code>new()</code></a> function can be used to examine and
68 modify the contents of the .packlist. Items may be added/deleted from the
69 .packlist by modifying the hash. If the value associated with a hash key is a
70 scalar, the entry written to the .packlist by any subsequent <a href="#item_write"><code>write()</code></a> will be a
71 simple filename. If the value is a hash, the entry written will be the
72 filename followed by the key=value pairs from the hash. Reading back the
73 .packlist will recreate the original entries.</p>
74 <p>
75 </p>
76 <hr />
77 <h1><a name="functions">FUNCTIONS</a></h1>
78 <dl>
79 <dt><strong><a name="item_new"><code>new()</code></a></strong>
81 <dd>
82 <p>This takes an optional parameter, the name of a .packlist. If the file exists,
83 it will be opened and the contents of the file will be read. The <a href="#item_new"><code>new()</code></a> method
84 returns a reference to a hash. This hash holds an entry for each line in the
85 .packlist. In the case of old-style .packlists, the value associated with each
86 key is undef. In the case of new-style .packlists, the value associated with
87 each key is a hash containing the key=value pairs following the filename in the
88 .packlist.</p>
89 </dd>
90 </li>
91 <dt><strong><a name="item_read"><code>read()</code></a></strong>
93 <dd>
94 <p>This takes an optional parameter, the name of the .packlist to be read. If
95 no file is specified, the .packlist specified to <a href="#item_new"><code>new()</code></a> will be read. If the
96 .packlist does not exist, Carp::croak will be called.</p>
97 </dd>
98 </li>
99 <dt><strong><a name="item_write"><code>write()</code></a></strong>
101 <dd>
102 <p>This takes an optional parameter, the name of the .packlist to be written. If
103 no file is specified, the .packlist specified to <a href="#item_new"><code>new()</code></a> will be overwritten.</p>
104 </dd>
105 </li>
106 <dt><strong><a name="item_validate"><code>validate()</code></a></strong>
108 <dd>
109 <p>This checks that every file listed in the .packlist actually exists. If an
110 argument which evaluates to true is given, any missing files will be removed
111 from the internal hash. The return value is a list of the missing files, which
112 will be empty if they all exist.</p>
113 </dd>
114 </li>
115 <dt><strong><a name="item_packlist_file"><code>packlist_file()</code></a></strong>
117 <dd>
118 <p>This returns the name of the associated .packlist file</p>
119 </dd>
120 </li>
121 </dl>
123 </p>
124 <hr />
125 <h1><a name="example">EXAMPLE</a></h1>
126 <p>Here's <code>modrm</code>, a little utility to cleanly remove an installed module.</p>
127 <pre>
128 #!/usr/local/bin/perl -w</pre>
129 <pre>
130 use strict;
131 use IO::Dir;
132 use ExtUtils::Packlist;
133 use ExtUtils::Installed;</pre>
134 <pre>
135 sub emptydir($) {
136 my ($dir) = @_;
137 my $dh = IO::Dir-&gt;new($dir) || return(0);
138 my @count = $dh-&gt;read();
139 $dh-&gt;close();
140 return(@count == 2 ? 1 : 0);
141 }</pre>
142 <pre>
143 # Find all the installed packages
144 print(&quot;Finding all installed modules...\n&quot;);
145 my $installed = ExtUtils::Installed-&gt;new();</pre>
146 <pre>
147 foreach my $module (grep(!/^Perl$/, $installed-&gt;modules())) {
148 my $version = $installed-&gt;version($module) || &quot;???&quot;;
149 print(&quot;Found module $module Version $version\n&quot;);
150 print(&quot;Do you want to delete $module? [n] &quot;);
151 my $r = &lt;STDIN&gt;; chomp($r);
152 if ($r &amp;&amp; $r =~ /^y/i) {
153 # Remove all the files
154 foreach my $file (sort($installed-&gt;files($module))) {
155 print(&quot;rm $file\n&quot;);
156 unlink($file);
158 my $pf = $installed-&gt;packlist($module)-&gt;packlist_file();
159 print(&quot;rm $pf\n&quot;);
160 unlink($pf);
161 foreach my $dir (sort($installed-&gt;directory_tree($module))) {
162 if (emptydir($dir)) {
163 print(&quot;rmdir $dir\n&quot;);
164 rmdir($dir);
168 }</pre>
170 </p>
171 <hr />
172 <h1><a name="author">AUTHOR</a></h1>
173 <p>Alan Burlison &lt;<a href="mailto:Alan.Burlison@uk.sun.com">Alan.Burlison@uk.sun.com</a>&gt;</p>
174 <table border="0" width="100%" cellspacing="0" cellpadding="3">
175 <tr><td class="block" style="background-color: #cccccc" valign="middle">
176 <big><strong><span class="block">&nbsp;ExtUtils::Packlist - manage .packlist files</span></strong></big>
177 </td></tr>
178 </table>
180 </body>
182 </html>