EXTUTILS::PACKLIST(3pm)

okay bestie, welcome to ExtUtils::Packlist(3pm) β€” the Perl Programmers Reference Guide page that’s literally here to help you manage .packlist files. it’s giving β€œsmall but crucial install bookkeeping” and we’re gonna read it together, no cap. 🫢✨

🌸 NAME 🌸

ExtUtils::Packlist β€” manage .packlist files. that’s the whole assignment, periodt. πŸ’…

✨ SYNOPSIS ✨

the code vibe is:

          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' };

πŸ¦‹ DESCRIPTION πŸ¦‹

ExtUtils::Packlist provides a standard way to manage .packlist files. functions are provided to read and write .packlist files. the original .packlist format is a simple list of absolute pathnames, one per line. in addition, this package supports an extended format, where as well as a filename each line may contain a list of attributes in the form of a space separated list of key=value pairs. this is used by the installperl script to differentiate between files and links, for example. extended-format behavior, honestly iconic. 🌈

🧰 USAGE 🧰

the hash reference returned by the new() function can be used to examine and modify the contents of the .packlist. items may be added/deleted from the .packlist by modifying the hash. 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. reading back the .packlist will recreate the original entries. round-trip realness! πŸ’–

πŸ› οΈ FUNCTIONS πŸ› οΈ

🌱 new()

this takes an optional parameter, the name of a .packlist. if the file exists, it will be opened and the contents of the file will be read. the new() method returns a reference to a hash. this hash holds an entry for each line in the .packlist. in the case of old-style .packlists, the value associated with each key is undef. in the case of new-style .packlists, the value associated with each key is a hash containing the key=value pairs following the filename in the .packlist. very hash, very demure. 😌

πŸ“– read()

this takes an optional parameter, the name of the .packlist to be read. if no file is specified, the .packlist specified to new() will be read. if the .packlist does not exist, Carp::croak will be called.

bestie, missing .packlist = Carp::croak city, fr fr. 😭

✍️ write()

this takes an optional parameter, the name of the .packlist to be written. if no file is specified, the .packlist specified to new() will be overwritten. overwritten! not a drill! πŸ’…

βœ… validate()

this checks that every file listed in the .packlist actually exists. if an argument which evaluates to true is given, any missing files will be removed from the internal hash. the return value is a list of the missing files, which will be empty if they all exist. so the empty list is the good ending. πŸŽ€

πŸ—‚οΈ packlist_file()

this returns the name of the associated .packlist file. short, sweet, iconic. πŸ¦‹

🌟 EXAMPLE 🌟

here’s β€œmodrm”, a little utility to cleanly remove an installed module. it’s giving β€œyes, I will delete a whole module with vibes and a confirmation prompt.” 🫢

           #!/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 πŸ‘‘

written by Alan Burlison <Alan.Burlison@uk.sun.com> β€” periodt. πŸ’–


and that’s the page, bestie! this manual is from perl v5.42.3, dated 2026-11-03, and it’s literally ExtUtils::Packlist(3pm) β€” go forth and manage those .packlist files with main character energy. πŸ«Άβœ¨πŸŽ€

πŸ“¦ where this page comes from