{
    "content": [
        {
            "type": "text",
            "text": "# ExtUtils::Packlist (perldoc)\n\n## NAME\n\nExtUtils::Packlist - manage .packlist files\n\n## SYNOPSIS\n\nuse ExtUtils::Packlist;\nmy ($pl) = ExtUtils::Packlist->new('.packlist');\n$pl->read('/an/old/.packlist');\nmy @missingfiles = $pl->validate();\n$pl->write('/a/new/.packlist');\n$pl->{'/some/file/name'}++;\nor\n$pl->{'/some/other/file/name'} = { type => 'file',\nfrom => '/some/file' };\n\n## DESCRIPTION\n\nExtUtils::Packlist provides a standard way to manage .packlist files. Functions are provided to\nread and write .packlist files. The original .packlist format is a simple list of absolute\npathnames, one per line. In addition, this package supports an extended format, where as well as\na filename each line may contain a list of attributes in the form of a space separated list of\nkey=value pairs. This is used by the installperl script to differentiate between files and\nlinks, for example.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **USAGE**\n- **FUNCTIONS** (5 subsections)\n- **EXAMPLE**\n- **AUTHOR**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "ExtUtils::Packlist",
        "section": "",
        "mode": "perldoc",
        "summary": "ExtUtils::Packlist - manage .packlist files",
        "synopsis": "use ExtUtils::Packlist;\nmy ($pl) = ExtUtils::Packlist->new('.packlist');\n$pl->read('/an/old/.packlist');\nmy @missingfiles = $pl->validate();\n$pl->write('/a/new/.packlist');\n$pl->{'/some/file/name'}++;\nor\n$pl->{'/some/other/file/name'} = { type => 'file',\nfrom => '/some/file' };",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [
            "Here's \"modrm\", a little utility to cleanly remove an installed module.",
            "#!/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)->packlistfile();",
            "print(\"rm $pf\\n\");",
            "unlink($pf);",
            "foreach my $dir (sort($installed->directorytree($module))) {",
            "if (emptydir($dir)) {",
            "print(\"rmdir $dir\\n\");",
            "rmdir($dir);"
        ],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "USAGE",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "FUNCTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "new",
                        "lines": 7
                    },
                    {
                        "name": "read",
                        "lines": 4
                    },
                    {
                        "name": "write",
                        "lines": 3
                    },
                    {
                        "name": "validate",
                        "lines": 4
                    },
                    {
                        "name": "packlist_file",
                        "lines": 2
                    }
                ]
            },
            {
                "name": "EXAMPLE",
                "lines": 44,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "ExtUtils::Packlist - manage .packlist files\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use ExtUtils::Packlist;\nmy ($pl) = ExtUtils::Packlist->new('.packlist');\n$pl->read('/an/old/.packlist');\nmy @missingfiles = $pl->validate();\n$pl->write('/a/new/.packlist');\n\n$pl->{'/some/file/name'}++;\nor\n$pl->{'/some/other/file/name'} = { type => 'file',\nfrom => '/some/file' };\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "ExtUtils::Packlist provides a standard way to manage .packlist files. Functions are provided to\nread and write .packlist files. The original .packlist format is a simple list of absolute\npathnames, one per line. In addition, this package supports an extended format, where as well as\na filename each line may contain a list of attributes in the form of a space separated list of\nkey=value pairs. This is used by the installperl script to differentiate between files and\nlinks, for example.\n",
                "subsections": []
            },
            "USAGE": {
                "content": "The hash reference returned by the new() function can be used to examine and modify the contents\nof the .packlist. Items may be added/deleted from the .packlist by modifying the hash. If the\nvalue associated with a hash key is a scalar, the entry written to the .packlist by any\nsubsequent write() will be a simple filename. If the value is a hash, the entry written will be\nthe filename followed by the key=value pairs from the hash. Reading back the .packlist will\nrecreate the original entries.\n",
                "subsections": []
            },
            "FUNCTIONS": {
                "content": "",
                "subsections": [
                    {
                        "name": "new",
                        "content": "This takes an optional parameter, the name of a .packlist. If the file exists, it will be\nopened and the contents of the file will be read. The new() method returns a reference to a\nhash. This hash holds an entry for each line in the .packlist. In the case of old-style\n.packlists, the value associated with each key is undef. In the case of new-style\n.packlists, the value associated with each key is a hash containing the key=value pairs\nfollowing the filename in the .packlist.\n"
                    },
                    {
                        "name": "read",
                        "content": "This takes an optional parameter, the name of the .packlist to be read. If no file is\nspecified, the .packlist specified to new() will be read. If the .packlist does not exist,\nCarp::croak will be called.\n"
                    },
                    {
                        "name": "write",
                        "content": "This takes an optional parameter, the name of the .packlist to be written. If no file is\nspecified, the .packlist specified to new() will be overwritten.\n"
                    },
                    {
                        "name": "validate",
                        "content": "This checks that every file listed in the .packlist actually exists. If an argument which\nevaluates to true is given, any missing files will be removed from the internal hash. The\nreturn value is a list of the missing files, which will be empty if they all exist.\n"
                    },
                    {
                        "name": "packlist_file",
                        "content": "This returns the name of the associated .packlist file\n"
                    }
                ]
            },
            "EXAMPLE": {
                "content": "Here's \"modrm\", a little utility to cleanly remove an installed module.\n\n#!/usr/local/bin/perl -w\n\nuse strict;\nuse IO::Dir;\nuse ExtUtils::Packlist;\nuse ExtUtils::Installed;\n\nsub emptydir($) {\nmy ($dir) = @;\nmy $dh = IO::Dir->new($dir) || return(0);\nmy @count = $dh->read();\n$dh->close();\nreturn(@count == 2 ? 1 : 0);\n}\n\n# Find all the installed packages\nprint(\"Finding all installed modules...\\n\");\nmy $installed = ExtUtils::Installed->new();\n\nforeach my $module (grep(!/^Perl$/, $installed->modules())) {\nmy $version = $installed->version($module) || \"???\";\nprint(\"Found module $module Version $version\\n\");\nprint(\"Do you want to delete $module? [n] \");\nmy $r = <STDIN>; chomp($r);\nif ($r && $r =~ /^y/i) {\n# Remove all the files\nforeach my $file (sort($installed->files($module))) {\nprint(\"rm $file\\n\");\nunlink($file);\n}\nmy $pf = $installed->packlist($module)->packlistfile();\nprint(\"rm $pf\\n\");\nunlink($pf);\nforeach my $dir (sort($installed->directorytree($module))) {\nif (emptydir($dir)) {\nprint(\"rmdir $dir\\n\");\nrmdir($dir);\n}\n}\n}\n}\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Alan Burlison <Alan.Burlison@uk.sun.com>\n",
                "subsections": []
            }
        }
    }
}