Direct...ctured(3pm)
β¨ NAME β¨
Directory::Scratch::Structured β okay bestie, this one creates temporary files and directories from a structured description. That's it, that's the whole vibe. π
πΈ SYNOPSIS πΈ
Like, here's the whole thing in action:
my %tree_structure =
(
dir_1 =>
{
subdir_1 =>{},
file_1 =>[],
file_a => [],
},
dir_2 =>
{
subdir_2 =>
{
file_22 =>[],
file_2a =>[],
},
file_2 =>[],
file_a =>['12345'],
file_b =>[],
},
file_0 => [] ,
) ;
use Directory::Scratch::Structured qw(create_structured_tree) ;
my $temporary_directory = create_structured_tree(%tree_structure) ;
or
use Directory::Scratch ;
use Directory::Scratch::Structured qw(piggyback_directory_scratch) ;
my $temporary_directory = Directory::Scratch->new;
$temporary_directory->create_structured_tree(%tree_structure) ;
Two paths, same destination. Pick your fighter. π«Ά
π¦ DESCRIPTION π¦
This module adds a create_structured_tree subroutine to the Directory::Scratch.
That's the tea. It's giving "small module, big feelings." π
π DOCUMENTATION π
okay so storytime. π I needed a subroutine to create a bunch of temporary directories and files while running tests. I used the excellent Directory::Scratch to implement such a functionality. I proposed the subroutine to the Directory::Scratch author but he preferred to implement a subroutine using an unstructured input data based on the fact that Directory::Scratch didn't use structured data. This is, IMHO, flawed design, though it may require slightly less typing.
I proposed a hybrid solution to reduce the amount of subroutines and integrate the subroutine using structured input into Directory::Scratch but we didn't reach an agreement on the API. Instead I decided that I would piggyback on Directory::Scratch.
You can access create_structured_tree through a subroutine or a method through a Directory::Scratch object.
Whichever interface you choose, the argument to the create_structured_tree consists of tuples (hash entries). The key represents the name of the object to create in the directory.
If the value is of type:
- ARRAY β A file will be created, it's contents are the contents of the array (See
Directory::Scratch) - HASH β A directory will be created. the element of the hash will also be , recursively, created
- OTHER β The subroutine will croak.
β οΈ fr fr, hand it anything that isn't an ARRAY or a HASH and it croaks. No cap.
π SUBROUTINES/METHODS π
π create_structured_tree
use Directory::Scratch::Structured qw(create_structured_tree) ;
my $temporary_directory = create_structured_tree(%tree_structure) ;
my $base = $temporary_directory->base() ;
Returns a default Directory::Scratch object. Iconic. π
π directory_scratch_create_structured_tree
Adds create_structured_tree to Directory::Scratch when you Load Directory::Scratch::Structured with the piggyback_directory_scratch option.
use Directory::Scratch ;
use Directory::Scratch::Structured qw(piggyback_directory_scratch) ;
my $temporary_directory = Directory::Scratch->new;
$temporary_directory->create_structured_tree(%tree_structure) ;
π§ _create_structured_tree
Used internally by both interfaces. (the little underscore in front? yeah, that's the "don't touch me" haircut. π)
π piggyback
Used internally to piggyback Directory::Scratch. Internal vibes only.
π BUGS AND LIMITATIONS π
None so far. Not a single one. The audacity, honestly. πβ¨
π AUTHOR π
Khemir Nadim ibn Hamouda
CPAN ID: NKH
mailto:nadim@khemir.net
π LICENSE AND COPYRIGHT π
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
π SUPPORT π
You can find documentation for this module with the perldoc command.
perldoc Directory::Scratch::Structured
You can also look for information at:
- AnnoCPAN: Annotated CPAN documentation
<http://annocpan.org/dist/Directory-Scratch-Structured>
- RT: CPAN's request tracker
Please report any bugs or feature requests to L <bug-directory-scratch-structured@rt.cpan.org>.
We will be notified, and then you'll automatically be notified of progress on your bug as we make changes.
- Search CPAN
<http://search.cpan.org/dist/Directory-Scratch-Structured>
β SEE ALSO β
Directory::Scratch
and that's the whole page bestie!! π¦πΈ this lil doc is living its best life as Direct...ctured(3pm) β yes the name got squished, it's giving "username taken so i added dots" π β shipped as User Contributed Perl Documentation from perl v5.34.0, dated 2022-06-13. mwah, go build some temporary trees. πβ¨π
π¦ where this page comes from
- debian bookworm: libdirectory-scratch-structured-perl 0.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdirectory-scratch-structured-perl 0.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdirectory-scratch-structured-perl 0.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdirectory-scratch-structured-perl 0.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdirectory-scratch-structured-perl 0.04-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