{
    "mode": "perldoc",
    "parameter": "File::Listing",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/File%3A%3AListing/json",
    "generated": "2026-06-15T13:25:00Z",
    "synopsis": "use File::Listing qw(parsedir);\n$ENV{LANG} = \"C\";  # dates in non-English locales not supported\nforeach my $file (parsedir(`ls -l`)) {\nmy ($name, $type, $size, $mtime, $mode) = @$file;\nnext if $type ne 'f'; # plain file\n#...\n}\n# directory listing can also be read from a file\nopen my $listing, \"zcat ls-lR.gz|\";\n$dir = parsedir($listing, '+0000');",
    "sections": {
        "NAME": {
            "content": "File::Listing - Parse directory listing\n",
            "subsections": []
        },
        "VERSION": {
            "content": "version 6.14\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use File::Listing qw(parsedir);\n$ENV{LANG} = \"C\";  # dates in non-English locales not supported\nforeach my $file (parsedir(`ls -l`)) {\nmy ($name, $type, $size, $mtime, $mode) = @$file;\nnext if $type ne 'f'; # plain file\n#...\n}\n\n# directory listing can also be read from a file\nopen my $listing, \"zcat ls-lR.gz|\";\n$dir = parsedir($listing, '+0000');\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module exports a single function called \"parsedir\", which can be used to parse directory\nlistings.\n",
            "subsections": []
        },
        "FUNCTIONS": {
            "content": "parsedir\nmy $dir = parsedir( $listing );\nmy $dir = parsedir( $listing, $timezone );\nmy $dir = parsedir( $listing, $timezone, $type );\nmy $dir = parsedir( $listing, $timezone, $type, $error );\nmy @files = parsedir( $listing );\nmy @files = parsedir( $listing, $timezone );\nmy @files = parsedir( $listing, $timezone, $type );\nmy @files = parsedir( $listing, $timezone, $type, $error );\n\nThe first parameter ($listing) is the directory listing to parse. It can be a scalar, a\nreference to an array of directory lines or a glob representing a filehandle to read the\ndirectory listing from.\n\nThe second parameter ($timezone) is the time zone to use when parsing time stamps in the\nlisting. If this value is undefined, then the local time zone is assumed.\n\nThe third parameter ($type) is the type of listing to assume. Currently supported formats are\n'unix', 'apache' and 'dosftp'. The default value is 'unix'. Ideally, the listing type should be\ndetermined automatically.\n\nThe fourth parameter ($error) specifies how unparseable lines should be treated. Values can be\n'ignore', 'warn' or a code reference. Warn means that the perl warn() function will be called.\nIf a code reference is passed, then this routine will be called and the return value from it\nwill be incorporated in the listing. The default is 'ignore'.\n\nOnly the first parameter is mandatory.\n\n# list context\nforeach my $file (parsedir($listing)) {\nmy($name, $type, $size, $mtime, $mode) = @$file;\n}\n\n# scalar context\nmy $dir = parsedir($listing);\nforeach my $file (@$dir) {\nmy($name, $type, $size, $mtime, $mode) = @$file;\n}\n\nThe return value from parsedir() is a list of directory entries. In a scalar context the return\nvalue is a reference to the list. The directory entries are represented by an array consisting\nof:\n\nname\nThe name of the file.\n\ntype\nOne of: \"f\" file, \"d\" directory, \"l\" symlink, \"?\" unknown.\n\nsize\nThe size of the file.\n\ntime\nThe number of seconds since January 1, 1970.\n\nmode\nBitmask a la the mode returned by \"stat\".\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "File::Listing::Ftpcopy\nProvides the same interface but uses XS and the parser implementation from \"ftpcopy\".\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Original author: Gisle Aas\n\nCurrent maintainer: Graham Ollis <plicease@cpan.org>\n\nContributors:\n\nAdam Kennedy\n\nAdam Sjogren\n\nAlex Kapranoff\n\nAlexey Tourbin\n\nAndreas J. Koenig\n\nBill Mann\n\nBron Gondwana\n\nDAVIDRW\n\nDaniel Hedlund\n\nDavid E. Wheeler\n\nDavid Steinbrunner\n\nErik Esterer\n\nFWILES\n\nFather Chrysostomos\n\nGavin Peters\n\nGraeme Thompson\n\nHans-H. Froehlich\n\nIan Kilgore\n\nJacob J\n\nMark Stosberg\n\nMike Schilli\n\nOndrej Hanak\n\nPeter John Acklam\n\nPeter Rabbitson\n\nRobert Stone\n\nRolf Grossmann\n\nSean M. Burke\n\nSimon Legner\n\nSlaven Rezic\n\nSpiros Denaxas\n\nSteve Hay\n\nTodd Lipcon\n\nTom Hukins\n\nTony Finch\n\nToru Yamaguchi\n\nVille Skyttä\n\nYuri Karaban\n\nZefram\n\namire80\n\njefflee\n\njohn9art\n\nmschilli\n\nmurphy\n\nphrstbrn\n\nruff\n\nsasao\n\nuid39246\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "This software is copyright (c) 1996-2020 by Gisle Aas.\n\nThis is free software; you can redistribute it and/or modify it under the same terms as the Perl\n5 programming language system itself.\n",
            "subsections": []
        }
    },
    "summary": "File::Listing - Parse directory listing",
    "flags": [],
    "examples": [],
    "see_also": []
}