{"id":7457,"date":"2022-12-20T19:38:10","date_gmt":"2022-12-20T22:38:10","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/filelisting-man3\/"},"modified":"2022-12-20T19:38:10","modified_gmt":"2022-12-20T22:38:10","slug":"filelisting-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/filelisting-man3\/","title":{"rendered":"File::Listing (man3)"},"content":{"rendered":"<h1 align=\"center\">File::Listing<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#VERSION\">VERSION<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#FUNCTIONS\">FUNCTIONS<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#AUTHOR\">AUTHOR<\/a><br \/> <a href=\"#COPYRIGHT AND LICENSE\">COPYRIGHT AND LICENSE<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">File::Listing \u2212 Parse directory listing<\/p>\n<h2>VERSION <a name=\"VERSION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">version 6.14<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">use File::Listing qw(parse_dir); <br \/> $ENV{LANG} = &#8220;C&#8221;; # dates in non\u2212English locales not supported <br \/> foreach my $file (parse_dir(`ls \u2212l`)) { <br \/> my ($name, $type, $size, $mtime, $mode) = @$file; <br \/> next if $type ne &#8216;f&#8217;; # plain file <br \/> #&#8230; <br \/> } <br \/> # directory listing can also be read from a file <br \/> open my $listing, &#8220;zcat ls\u2212lR.gz|&#8221;; <br \/> $dir = parse_dir($listing, &#8216;+0000&#8217;);<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This module exports a single function called &#8220;parse_dir&#8221;, which can be used to parse directory listings.<\/p>\n<h2>FUNCTIONS <a name=\"FUNCTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>parse_dir<\/b> <br \/> my $dir = parse_dir( $listing ); <br \/> my $dir = parse_dir( $listing, $time_zone ); <br \/> my $dir = parse_dir( $listing, $time_zone, $type ); <br \/> my $dir = parse_dir( $listing, $time_zone, $type, $error ); <br \/> my @files = parse_dir( $listing ); <br \/> my @files = parse_dir( $listing, $time_zone ); <br \/> my @files = parse_dir( $listing, $time_zone, $type ); <br \/> my @files = parse_dir( $listing, $time_zone, $type, $error );<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The first parameter ($listing) is the directory listing to parse. It can be a scalar, a reference to an array of directory lines or a glob representing a filehandle to read the directory listing from.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The second parameter ($time_zone) is the time zone to use when parsing time stamps in the listing. If this value is undefined, then the local time zone is assumed.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The third parameter ($type) is the type of listing to assume. Currently supported formats are &#8216;unix&#8217;, &#8216;apache&#8217; and &#8216;dosftp&#8217;. The default value is &#8216;unix&#8217;. Ideally, the listing type should be determined automatically.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The fourth parameter ($error) specifies how unparseable lines should be treated. Values can be &#8216;ignore&#8217;, &#8216;warn&#8217; or a code reference. Warn means that the perl <b>warn()<\/b> function will be called. If a code reference is passed, then this routine will be called and the return value from it will be incorporated in the listing. The default is &#8216;ignore&#8217;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Only the first parameter is mandatory.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"># list context <br \/> foreach my $file (parse_dir($listing)) { <br \/> my($name, $type, $size, $mtime, $mode) = @$file; <br \/> } <br \/> # scalar context <br \/> my $dir = parse_dir($listing); <br \/> foreach my $file (@$dir) { <br \/> my($name, $type, $size, $mtime, $mode) = @$file; <br \/> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The return value from <b>parse_dir()<\/b> is a list of directory entries. In a scalar context the return value is a reference to the list. The directory entries are represented by an array consisting of: <br \/> name<\/p>\n<p style=\"margin-left:17%;\">The name of the file.<\/p>\n<p style=\"margin-left:11%;\">type<\/p>\n<p style=\"margin-left:17%;\">One of: &#8220;f&#8221; file, &#8220;d&#8221; directory, &#8220;l&#8221; symlink, &#8220;?&#8221; unknown.<\/p>\n<p style=\"margin-left:11%;\">size<\/p>\n<p style=\"margin-left:17%;\">The size of the file.<\/p>\n<p style=\"margin-left:11%;\">time<\/p>\n<p style=\"margin-left:17%;\">The number of seconds since January 1, 1970.<\/p>\n<p style=\"margin-left:11%;\">mode<\/p>\n<p style=\"margin-left:17%;\">Bitmask a la the mode returned by &#8220;stat&#8221;.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">File::Listing::Ftpcopy<\/p>\n<p style=\"margin-left:17%;\">Provides the same interface but uses <small>XS<\/small> and the parser implementation from &#8220;ftpcopy&#8221;.<\/p>\n<h2>AUTHOR <a name=\"AUTHOR\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Original author: Gisle Aas<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Current maintainer: Graham Ollis <plicease@cpan.org><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Contributors:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Adam Kennedy<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Adam Sjogren<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Alex Kapranoff<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Alexey Tourbin<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Andreas J. Koenig<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Bill Mann<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Bron Gondwana<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><small>DAVIDRW<\/small><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Daniel Hedlund<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">David E. Wheeler<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">David Steinbrunner<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Erik Esterer<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><small>FWILES<\/small><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Father Chrysostomos<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Gavin Peters<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Graeme Thompson<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Hans-H. Froehlich<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Ian Kilgore<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Jacob J<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Mark Stosberg<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Mike Schilli<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Ondrej Hanak<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Peter John Acklam<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Peter Rabbitson<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Robert Stone<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Rolf Grossmann<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Sean M. Burke<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Simon Legner<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Slaven Rezic<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Spiros Denaxas<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Steve Hay<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Todd Lipcon<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Tom Hukins<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Tony Finch<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Toru Yamaguchi<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Ville Skytt\u00c3\u00a4<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Yuri Karaban<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Zefram<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">amire80<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">jefflee<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">john9art<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">mschilli<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">murphy<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">phrstbrn<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">ruff<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">sasao<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">uid39246<\/p>\n<h2>COPYRIGHT AND LICENSE <a name=\"COPYRIGHT AND LICENSE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This software is copyright (c) 1996\u22122020 by Gisle Aas.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This is free software; you can redistribute it and\/or modify it under the same terms as the Perl 5 programming language system itself.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  File::Listing \u2212 Parse directory listing <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3769,3007],"class_list":["post-7457","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-filelisting","tag-man3"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7457","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7457"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7457\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}