1Directory::Scratch::StrUuscetrurCeodn(t3r)ibuted Perl DoDciurmeecnttoartyi:o:nScratch::Structured(3)
2
3
4
6 Directory::Scratch::Structured - creates temporary files and directories from a structured description
7
9 my %tree_structure =
10 (
11 dir_1 =>
12 {
13 subdir_1 =>{},
14 file_1 =>[],
15 file_a => [],
16 },
17 dir_2 =>
18 {
19 subdir_2 =>
20 {
21 file_22 =>[],
22 file_2a =>[],
23 },
24 file_2 =>[],
25 file_a =>['12345'],
26 file_b =>[],
27 },
28
29 file_0 => [] ,
30 ) ;
31
32 use Directory::Scratch::Structured qw(create_structured_tree) ;
33 my $temporary_directory = create_structured_tree(%tree_structure) ;
34
35 or
36
37 use Directory::Scratch ;
38 use Directory::Scratch::Structured qw(piggyback_directory_scratch) ;
39
40 my $temporary_directory = Directory::Scratch->new;
41 $temporary_directory->create_structured_tree(%tree_structure) ;
42
44 This module adds a create_structured_tree subroutine to the
45 Directory::Scratch.
46
48 I needed a subroutine to create a bunch of temporary directories and
49 files while running tests. I used the excellent Directory::Scratch to
50 implement such a functionality. I proposed the subroutine to the
51 Directory::Scratch author but he preferred to implement a subroutine
52 using an unstructured input data based on the fact that
53 Directory::Scratch didn't use structured data. This is, IMHO, flawed
54 design, though it may require slightly less typing.
55
56 I proposed a hybrid solution to reduce the amount of subroutines and
57 integrate the subroutine using structured input into Directory::Scratch
58 but we didn't reach an agreement on the API. Instead I decided that I
59 would piggyback on Directory::Scratch.
60
61 You can access create_structured_tree through a subroutine or a method
62 through a Directory::Scratch object.
63
64 Whichever interface you choose, the argument to the
65 create_structured_tree consists of tuples (hash entries). The key
66 represents the name of the object to create in the directory.
67
68 If the value is of type:
69
70 ARRAY
71 A file will be created, it's contents are the contents of the array
72 (See Directory::Scratch)
73
74 HASH
75 A directory will be created. the element of the hash will also be ,
76 recursively, created
77
78 OTHER
79 The subroutine will croak.
80
82 create_structured_tree
83 use Directory::Scratch::Structured qw(create_structured_tree) ;
84
85 my $temporary_directory = create_structured_tree(%tree_structure) ;
86 my $base = $temporary_directory->base() ;
87
88 Returns a default Directory::Scratch object.
89
90 directory_scratch_create_structured_tree
91 Adds create_structured_tree to Directory::Scratch when you Load
92 Directory::Scratch::Structured with the piggyback_directory_scratch
93 option.
94
95 use Directory::Scratch ;
96 use Directory::Scratch::Structured qw(piggyback_directory_scratch) ;
97
98 my $temporary_directory = Directory::Scratch->new;
99 $temporary_directory->create_structured_tree(%tree_structure) ;
100
101 _create_structured_tree
102 Used internally by both interfaces
103
104 piggyback
105 Used internally to piggyback Directory::Scratch.
106
108 None so far.
109
111 Khemir Nadim ibn Hamouda
112 CPAN ID: NKH
113 mailto:nadim@khemir.net
114
116 This program is free software; you can redistribute it and/or modify it
117 under the same terms as Perl itself.
118
120 You can find documentation for this module with the perldoc command.
121
122 perldoc Directory::Scratch::Structured
123
124 You can also look for information at:
125
126 · AnnoCPAN: Annotated CPAN documentation
127
128 <http://annocpan.org/dist/Directory-Scratch-Structured>
129
130 · RT: CPAN's request tracker
131
132 Please report any bugs or feature requests to L
133 <bug-directory-scratch-structured@rt.cpan.org>.
134
135 We will be notified, and then you'll automatically be notified of
136 progress on your bug as we make changes.
137
138 · Search CPAN
139
140 <http://search.cpan.org/dist/Directory-Scratch-Structured>
141
143 Directory::Scratch
144
145
146
147perl v5.28.0 2018-07-14 Directory::Scratch::Structured(3)