Arch::Inventory(3pm)
π Arch::Inventory π
okay bestie, so this is a Perl module β it's Arch::Inventory, from the User Contributed Perl Documentation corner of the manual, and it is literally a class representing a tree inventory. slay. πΈ
β¨ SYNOPSIS β¨
use Arch::Inventory qw(:category :type);
my $inv = Arch::Inventory->new; # use cwd
print Arch::Inventory->to_string($inv->get_root_entry), "\n";
print $inv->get_listing;
or (and this is the one everybody actually does, the main character route):
use Arch::Tree;
my $tree = Arch::Tree->new;
my $inv = $tree->get_inventory;
print $inv->get_listing;
π¦ DESCRIPTION π¦
Arch::Inventory generates a tree inventory. that's the whole vibe. π
so an inventory is a tree structure of elements, and each one represents a single directory entry of the source tree. and every single inventory entry is described by a hash with these fields, okay, listen:
categoryβ the classification of the tree element.categorycan be one ofTREE,SOURCE,PRECIOUS,BACKUPorJUNK. yes, precious. iconic. πuntaggedβ a boolean value telling you whether the element was first classified asSOURCEbut lacked an inventory id. so like, it wanted to be source so bad but the id was nowhere πtypeβ the tree element type.typecan be one ofFILE,DIRECTORYorSYMLINK.pathβ the complete path to the tree element, relative to the inventory base directory.idβ the element's inventory id. May beundef. πchildrenβ a hash of the element's direct children, idexed by their last path element. (yes, "idexed", that's how it's written, we don't fix the original here bestie)
heads up: thechildrenfield exists for elements of typeDIRECTORYonly. no kids for files, periodt.
and the category and type constants can be conveniently imported using the tags :category and :type. so convenient. obsessed. β¨
use Arch::Inventory qw(:category :type);
π METHODS π
here's the whole lineup, no cap:
new, directory, get_root_entry, get_entry, get_listing, annotate_fs, foreach, dump, to_string.
new [$dir]β create an inventory for$dir, or for the current directory if$diris not specified. lowkey does it all for you. πdirectoryβ returns the inventory's base directory as passed tonew. it remembers. π«Άget_root_entryβ returns the inventory element for the base directory.
and the root entry always has these properties, always, fr fr:
$root = {
category => TREE, # if {arch} exists, SOURCE otherwise
untagged => 1,
type => DIRECTORY,
path => '',
id => undef,
children => { ... },
};
get_entry $path/get_entry @path_elementsβ returns the inventory element for the specified path. the path can be given either as a single string or as a list of path elements, your call bestie.
if the element does not exist, undef is returned. π
and using an empty path or no path at all is equivalent to calling get_root_entry. same energy.
get_listingβ generates a textual inventory listing equivalent to the output of
tla inventory -tspbju -B --kind --ids --untagged
note, and this one matters: the output order is not equivalent to tla. instead of strict ASCII order of path names, a directory entry is always directly followed by its child entries. entries with the same parent entry are ASCII ordered. so like, family first, then alphabetical among siblings. cute actually. π
annotate_fs/annotate_fs $entryβ add filesystem information to$entry, or to every inventory entry if none is provided. this adds the fieldsstatandsymlinkto the annotated entries, which contain the output oflstatandreadlinkrespectively. it's giving receipts. π§foreach $coderefβ execute$codereffor every inventory entry, passing the entry as$_[0]. go little callback go. π₯dumpβ generates a dump of the inventory structure usingData::Dumper. for when you need to see everything. πto_string $inventory_elementβ generates an inventory line for the inventory element as produced bytla.
π BUGS π
Awaiting for your reports.
(that's it. that's the whole section. they're literally just waiting, bestie, the inbox is open, slide in.)
π AUTHORS π
- Mikhael Goikhman (
migo@homemail.com--Perl-GPL/arch-perl--devel). - Enno Cramer (
uebergeek@web.de--2003/arch-perl--devel).
πΈ SEE ALSO πΈ
for more information, see tla, Arch::Util.
and that's the whole page, bestie πβ¨ this was documented back in 2005-10-23 and shipped with perl v5.20.2 β so yeah, it's a classic, it ate, and it's still serving. go read your tree inventory, you got this. ππ¦π
π¦ where this page comes from
- ubuntu jammy: libarch-perl 0.5.2-2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms