ExtUti...cklist(3perl)

πŸ’– ExtUtils::Packlist β€” managing .packlist files, bestie edition πŸ’–

okay so this is ExtUtils::Packlist, part of the Perl Programmers Reference Guide (that's the 3perl section if you're keeping score πŸ‘‘). No cap, this little module is the one holding your installed-module receipts together. Let's get into it.


✨ NAME ✨

ExtUtils::Packlist β€” it manages .packlist files. That's the whole vibe.


🌸 SYNOPSIS 🌸

use ExtUtils::Packlist;
my ($pl) = ExtUtils::Packlist->new('.packlist');
$pl->read('/an/old/.packlist');
my @missing_files = $pl->validate();
$pl->write('/a/new/.packlist');

$pl->{'/some/file/name'}++;
   or
$pl->{'/some/other/file/name'} = { type => 'file',
                                   from => '/some/file' };

like... look at her. she's just a hash reference with a glow-up πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So ExtUtils::Packlist gives you a standard way to manage .packlist files. You get functions to read them and write them, periodt.

The original .packlist format is literally just a list of absolute pathnames, one per line. Simple. Iconic. No notes.

But also β€” this package supports an extended format, where each line can have a filename plus a list of attributes in the form of a space separated list of key=value pairs. The installperl script uses this to tell the difference between files and links, for example. it's giving "we evolved" 🧚


πŸ’œ USAGE πŸ’œ

The hash reference that new() hands back is your main character. You use it to examine and modify the contents of the .packlist. Add stuff, delete stuff, just by messing with the hash. 🫢

Here's the tea on how values get written:

  • If the value associated with a hash key is a scalar, the entry written to the .packlist by any subsequent write() will be a simple filename.
  • If the value is a hash, the entry written will be the filename followed by the key=value pairs from the hash.

And reading the .packlist back? It recreates the original entries. round trip, slay ✨


πŸŽ€ FUNCTIONS πŸŽ€

new()

Takes an optional parameter: the name of a .packlist. If that file exists, it gets opened and the contents get read. πŸ“–

new() returns a reference to a hash. That hash holds an entry for each line in the .packlist.

  • For old-style .packlists, the value associated with each key is undef.
  • For new-style .packlists, the value associated with each key is a hash containing the key=value pairs following the filename in the .packlist.

read()

Takes an optional parameter: the name of the .packlist to be read. If you don't specify a file, the .packlist you gave to new() gets read instead.

⚠️ If the .packlist does not exist, Carp::croak will be called. so like... it will absolutely yell at you 😭

write()

Takes an optional parameter: the name of the .packlist to be written. If you don't specify a file, the .packlist specified to new() gets overwritten.

πŸ’€ bestie. overwritten. be so serious about which file you're pointing this at.

validate()

Checks that every file listed in the .packlist actually exists. πŸ‘€

If you give it an argument that evaluates to true, any missing files get removed from the internal hash.

The return value is a list of the missing files β€” and that list will be empty if they all exist. clean check, no crumbs 🌈

packlist_file()

Returns the name of the associated .packlist file. that's it, that's the whole function, and she ate πŸ’…


⭐ EXAMPLE ⭐

Here's modrm β€” a little utility to cleanly remove an installed module. (yes she's little. yes she's powerful. πŸ”₯)

#!/usr/local/bin/perl -w

use strict;
use IO::Dir;
use ExtUtils::Packlist;
use ExtUtils::Installed;

sub emptydir($) {
    my ($dir) = @_;
    my $dh = IO::Dir->new($dir) || return(0);
    my @count = $dh->read();
    $dh->close();
    return(@count == 2 ? 1 : 0);
}

# Find all the installed packages
print("Finding all installed modules...\n");
my $installed = ExtUtils::Installed->new();

foreach my $module (grep(!/^Perl$/, $installed->modules())) {
   my $version = $installed->version($module) || "???";
   print("Found module $module Version $version\n");
   print("Do you want to delete $module? [n] ");
   my $r = <STDIN>; chomp($r);
   if ($r && $r =~ /^y/i) {
      # Remove all the files
      foreach my $file (sort($installed->files($module))) {
         print("rm $file\n");
         unlink($file);
      }
      my $pf = $installed->packlist($module)->packlist_file();
      print("rm $pf\n");
      unlink($pf);
      foreach my $dir (sort($installed->directory_tree($module))) {
         if (emptydir($dir)) {
            print("rmdir $dir\n");
            rmdir($dir);
         }
      }
   }
}

πŸ‘‘ AUTHOR πŸ‘‘

Alan Burlison <Alan.Burlison@uk.sun.com>


and that's the whole page, bestie πŸ’– this was perl v5.44.0, dated 2026-10-17, straight out of the Perl Programmers Reference Guide β€” ExtUti...cklist(3perl) for the search bar girlies. go forth and manage your packlists responsibly βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from
  • arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms