1File::Listing(3)      User Contributed Perl Documentation     File::Listing(3)
2
3
4

NAME

6       File::Listing - parse directory listing
7

SYNOPSIS

9        use File::Listing qw(parse_dir);
10        $ENV{LANG} = "C";  # dates in non-English locales not supported
11        for (parse_dir(`ls -l`)) {
12            ($name, $type, $size, $mtime, $mode) = @$_;
13            next if $type ne 'f'; # plain file
14            #...
15        }
16
17        # directory listing can also be read from a file
18        open(LISTING, "zcat ls-lR.gz|");
19        $dir = parse_dir(\*LISTING, '+0000');
20

DESCRIPTION

22       This module exports a single function called parse_dir(), which can be
23       used to parse directory listings.
24
25       The first parameter to parse_dir() is the directory listing to parse.
26       It can be a scalar, a reference to an array of directory lines or a
27       glob representing a filehandle to read the directory listing from.
28
29       The second parameter is the time zone to use when parsing time stamps
30       in the listing. If this value is undefined, then the local time zone is
31       assumed.
32
33       The third parameter is the type of listing to assume.  Currently
34       supported formats are 'unix', 'apache' and 'dosftp'.  The default value
35       is 'unix'.  Ideally, the listing type should be determined
36       automatically.
37
38       The fourth parameter specifies how unparseable lines should be treated.
39       Values can be 'ignore', 'warn' or a code reference.  Warn means that
40       the perl warn() function will be called.  If a code reference is
41       passed, then this routine will be called and the return value from it
42       will be incorporated in the listing.  The default is 'ignore'.
43
44       Only the first parameter is mandatory.
45
46       The return value from parse_dir() is a list of directory entries.  In a
47       scalar context the return value is a reference to the list.  The
48       directory entries are represented by an array consisting of [
49       $filename, $filetype, $filesize, $filetime, $filemode ].  The $filetype
50       value is one of the letters 'f', 'd', 'l' or '?'.  The $filetime value
51       is the seconds since Jan 1, 1970.  The $filemode is a bitmask like the
52       mode returned by stat().
53
55       Copyright 1996-2010, Gisle Aas
56
57       Based on lsparse.pl (from Lee McLoughlin's ftp mirror package) and
58       Net::FTP's parse_dir (Graham Barr).
59
60       This library is free software; you can redistribute it and/or modify it
61       under the same terms as Perl itself.
62
63
64
65perl v5.16.3                      2012-02-15                  File::Listing(3)
Impressum