File::Listing - Online Linux Manual PageSection : 3
Updated : 2022-01-21
Source : perl v5.34.0
Note : User Contributed Perl Documentation
NAMEFile::Listing − Parse directory listing
VERSIONversion 6.14
SYNOPSIS use File::Listing qw(parse_dir);
$ENV{LANG} = "C"; # dates in non−English locales not supported
foreach my $file (parse_dir(`ls −l`)) {
my ($name, $type, $size, $mtime, $mode) = @$file;
next if $type ne 'f'; # plain file
#...
}
# directory listing can also be read from a file
open my $listing, "zcat ls−lR.gz|";
$dir = parse_dir($listing, '+0000');
DESCRIPTIONThis module exports a single function called parse_dir, which can be used to parse directory listings.
FUNCTIONS
parse_dir my $dir = parse_dir( $listing );
my $dir = parse_dir( $listing, $time_zone );
my $dir = parse_dir( $listing, $time_zone, $type );
my $dir = parse_dir( $listing, $time_zone, $type, $error );
my @files = parse_dir( $listing );
my @files = parse_dir( $listing, $time_zone );
my @files = parse_dir( $listing, $time_zone, $type );
my @files = parse_dir( $listing, $time_zone, $type, $error );
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. 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. The third parameter ($type) is the type of listing to assume. Currently supported formats are 'unix', 'apache' and 'dosftp'. The default value is 'unix'. Ideally, the listing type should be determined automatically. The fourth parameter ($error) 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. # list context
foreach my $file (parse_dir($listing)) {
my($name, $type, $size, $mtime, $mode) = @$file;
}
# scalar context
my $dir = parse_dir($listing);
foreach my $file (@$dir) {
my($name, $type, $size, $mtime, $mode) = @$file;
}
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: name The name of the file. type One of: f file, d directory, l symlink, ? unknown. size The size of the file. time The number of seconds since January 1, 1970. mode Bitmask a la the mode returned by stat.
SEE ALSOFile::Listing::Ftpcopy Provides the same interface but uses XS and the parser implementation from ftpcopy.
AUTHOROriginal author: Gisle Aas Current maintainer: Graham Ollis <plicease@cpan.org> Contributors: Adam Kennedy Adam Sjogren Alex Kapranoff Alexey Tourbin Andreas J. Koenig Bill Mann Bron Gondwana DAVIDRW Daniel Hedlund David E. Wheeler David Steinbrunner Erik Esterer FWILES Father Chrysostomos Gavin Peters Graeme Thompson Hans-H. Froehlich Ian Kilgore Jacob J Mark Stosberg Mike Schilli Ondrej Hanak Peter John Acklam Peter Rabbitson Robert Stone Rolf Grossmann Sean M. Burke Simon Legner Slaven Rezic Spiros Denaxas Steve Hay Todd Lipcon Tom Hukins Tony Finch Toru Yamaguchi Ville Skyttä Yuri Karaban Zefram amire80 jefflee john9art mschilli murphy phrstbrn ruff sasao uid39246
COPYRIGHT AND LICENSEThis software is copyright (c) 1996−2020 by Gisle Aas. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. 0
Johanes Gumabo
Data Size : 17,840 byte
man-File::Listing.3pmBuild : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 6 / 166,075
Visitor ID : :
Visitor IP : 18.119.119.119 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|249|File::Listing.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\|
) (htmlprn|149|File::Listing.3pm|36/37|.el══─{─══. ds -- — |.el══─{─══. ds -- \|\(em\|
) (parse_manual_page_|249|File::Listing.3pm|43|br══─}─══|'br══─}─══
) (htmlprn|149|File::Listing.3pm|43|'br══─}─══ |'br══─}─══
)