MAN page from RedHat Other LWP.pm-5.48-2.i386.rpm
lib::File::Listing
Section: User Contributed Perl Documentation (3)
Updated: libwww-perl-5.48
Index NAME
parse_dir - parse directory listing
SYNOPSIS
use File::Listing; for (parse_dir(`ls -l`)) { ($name, $type, $size, $mtime, $mode) = @$_; next if $type ne 'f'; # plain file #... } # directory listing can also be read from a file open(LISTING, "zcat ls-lR.gz|"); $dir = parse_dir(\*LISTING, '+0000');
DESCRIPTION
The
parse_dir() routine can be used to parse directorylistings. Currently it only understand Unix
'ls -l' and
'ls -lR'format. It should eventually be able to most things you might getback from a ftp server file listing (LIST command), i.e. VMS listings,NT listings, DOS listings,...
The first parameter to parse_dir() is the directory listing to parse.It can be a scalar, a reference to an array of directory lines or aglob representing a filehandle to read the directory listing from.
The second parameter is the time zone to use when parsing time stampsin the listing. If this value is undefined, then the local time zone isassumed.
The third parameter is the type of listing to assume. The values willbe strings like `unix', `vms', `dos'. Currently only `unix' isimplemented and this is also the default value. Ideally, the listingtype should be determined automatically.
The fourth parameter specifies how unparseable lines should be treated.Values can be `ignore', `warn' or a code reference. Warn means thatthe perl warn() function will be called. If a code reference ispassed, then this routine will be called and the return value from itwill be incorporated in the listing. The default is `ignore'.
Only the first parameter is mandatory.
The return value from parse_dir() is a list of directory entries. Ina scalar context the return value is a reference to the list. Thedirectory entries are represented by an array consisting of [$filename, $filetype, $filesize, $filetime, $filemode ]. The$filetype value is one of the letters `f', `d', `l' or `?'. The$filetime value is the seconds since Jan 1, 1970. The$filemode is a bitmask like the mode returned by stat().
CREDITS
Based on lsparse.pl (from Lee McLoughlin's ftp mirror package) andNet::FTP's parse_dir (Graham Barr).
Index
- NAME
- SYNOPSIS
- DESCRIPTION
- CREDITS
This document was created byman2html,using the manual pages.