File::DirList(3pm)
β¨ NAME β¨
File::DirList β bestie, it hands you a sorted list of what's inside a directory π
Version 0.04 (yes she's been around a minute and she still slays)
π SYNOPSIS π
use File::DirList;
#
my @list = File::DirList::list('.', 'dn', 1, 0);
See? One line. Iconic. π
π¦ DESCRIPTION π¦
okay so this module is your girl for getting a list of directory content. That's the whole vibe. Under the hood it's literally just a simple wrapper around DirHandle and sort() β no cap, it's not doing anything shady, it's just making the sorting cute for you. π
She's got two methods, and we're gonna go through both, no skipping, because you deserve the full lore.
π list($dirName, $sortMode, $noLinks, $hideDotFiles, $showSelf)
This one produces a list, and it takes 5 parameters. Five. Count 'em. ποΈ
$dirNameβ the name of the directory you wanna list. That's it, that's the job.$sortModeβ this is the one that describes how the list should get sorted. It's a string containing the following symbols, and here's the tea: uppercase means reverse sort. π So lowercase and uppercase are NOT the same girl."d"or"D"β "Directory" sort.dmeans all the directories will precede files,Dmeans reverse."n"or"N"β sort by file (or subdirectory) name."i"or"I"β same as'n'but case insensitive."m"or"M"β sort by modification time."c"or"C"β sort by creation time."a"or"A"β sort by access time."s"or"S"β sort by size.
And here's the part you gotta know bestie: $sortMode is interpreted from left to right, like reading a text from your situationship. If the first comparison produces an equal result, the next one is used. So for example, the string 'din' produces a list where all the directories precede files, and directories and files are sorted by name case insensitively, with lowercase letters preceding upper case. Periodt. π
$noLinksβ if"true", symbolic links will not be examined. Set it on platforms without symlink support. (Real ones without symlinks, this one's for you π«Ά)$hideDotFilesβ if"true",'dot'files will not be reported. They're hidden, babes, we respect their privacy. π$showSelfβ if"true", the'.'directory entry will be reported. She's showing up to her own party. β¨
The returned value is an array reference, sorted exactly as described by $sortMode.
And the array elements? They're array references too, each one representing an item. (Nested arrays, we love a little structure. πͺ)
πΈ the individual item's array β 17 elements, let's go
"[0..12]"β the result ofstat()for this item. For valid symbolic links, the stat of the target item is returned. iykyk."[13]"β the name of the item."[14]"β is item a directory? Contains0for non-directory items,1for directories,2for'..',3for'.'. This one gets used by the"d or D"sorting. π"[15]"β is item a link?0for non-links,1for valid links,"-1"for invalid links."[16]"β link target."undef"for non-links, target path for links.
heads up:[15]and[16]are set to non-link if$examineLinksis"false".
π sortList($list, $sortMode)
This one is used to re-sort a list produced by "list()". Like a glow-up for an existing list, no reshuffling the whole directory needed. β¨
Parameters are:
$lisβ reference to a list produced by"list()". (yes it's spelled$lisin the docs, and honestly? she's doing her best, we don't fix her π«Ά)$sortModeβ the sorting rules.
The return value is similar to "list()". Same energy, new order. π
π EXPORT π
None by default. Nothing gets yeeted into your namespace unless you ask. Consent first, always. π
β SEE ALSO β
DirHandle, stat, lstat, sort β the whole friend group. Go say hi. π«Ά
π AUTHOR π
Daniel Podolsky, <tpaba@cpan.org> β the legend herself. π«‘
π COPYRIGHT AND LICENSE π
Copyright (C) 2006 by Daniel Podolsky, <tpaba@cpan.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.
and that's the whole page bestie!! this lil doc was brought to you by perl v5.36.0, dated 2022-10-13, for File::DirList(3pm) β go sort something cute, mwah ππΈπ
π¦ where this page comes from
- ubuntu noble: libfile-dirlist-perl 0.05-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libfile-dirlist-perl 0.05-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libfile-dirlist-perl 0.05-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms