Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

file::listing(3) [redhat man page]

File::Listing(3)					User Contributed Perl Documentation					  File::Listing(3)

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 directory listings. Currently it only understand Unix 'ls -l' and 'ls -lR' format. It should eventually be able to most things you might get back 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 a glob representing a filehandle to read the directory listing from. The second parameter 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. The third parameter is the type of listing to assume. The values will be strings like 'unix', 'vms', 'dos'. Currently only 'unix' is implemented and this is also the default value. Ideally, the listing type 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 that the perl warn() 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 'ignore'. Only the first parameter is mandatory. The return value from parse_dir() 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 [ $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) and Net::FTP's parse_dir (Graham Barr). libwww-perl-5.65 1999-03-20 File::Listing(3)

Check Out this Related Man Page

OPENDIR(3)								 1								OPENDIR(3)

opendir - Open directory handle

SYNOPSIS
resource opendir (string $path, [resource $context]) DESCRIPTION
Opens up a directory handle to be used in subsequent closedir(3), readdir(3), and rewinddir(3) calls. PARAMETERS
o $path - The directory path that is to be opened o $context - For a description of the $context parameter, refer to the streams section of the manual. RETURN VALUES
Returns a directory handle resource on success, or FALSE on failure. If $path is not a valid directory or the directory can not be opened due to permission restrictions or filesystem errors, opendir(3) returns FALSE and generates a PHP error of level E_WARNING. You can suppress the error output of opendir(3) by prepending '@' to the front of the function name. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.0.0 | | | | | | | $path supports the ftp:// URL wrapper. | | | | | 4.3.0 | | | | | | | $path can also be any URL which supports direc- | | | tory listing, however only the file:// URL wrap- | | | per supports this in PHP 4 | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 opendir(3) example <?php $dir = "/etc/php5/"; // Open a known directory, and proceed to read its contents if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { echo "filename: $file : filetype: " . filetype($dir . $file) . " "; } closedir($dh); } } ?> The above example will output something similar to: filename: . : filetype: dir filename: .. : filetype: dir filename: apache : filetype: dir filename: cgi : filetype: dir filename: cli : filetype: dir SEE ALSO
is_dir(3), readdir(3), dir(3). PHP Documentation Group OPENDIR(3)
Man Page