Revision 66022cbd
Von Sven Schöling vor fast 15 Jahren hinzugefügt
SL/MoreCommon.pm | ||
---|---|---|
88 | 88 |
return 0; |
89 | 89 |
} |
90 | 90 |
|
91 |
=item cross BLOCK ARRAY ARRAY |
|
92 |
|
|
93 |
Evaluates BLOCK for each combination of elements in ARRAY1 and ARRAY2 |
|
94 |
and returns a new list consisting of BLOCK's return values. |
|
95 |
The two elements are set to $a and $b. |
|
96 |
Note that those two are aliases to the original value so changing them |
|
97 |
will modify the input arrays. |
|
98 |
|
|
99 |
# append each to each |
|
100 |
@a = qw/a b c/; |
|
101 |
@b = qw/1 2 3/; |
|
102 |
@x = cross { "$a$b" } @a, @b; |
|
103 |
# returns a1, a2, a3, b1, b2, b3, c1, c2, c3 |
|
104 |
|
|
105 |
As cross expects an array but returns a list it is not directly chainable |
|
106 |
at the moment. This will be corrected in the future. |
|
107 |
|
|
108 |
=cut |
|
109 | 91 |
sub cross(&\@\@) { |
110 | 92 |
my $op = shift; |
111 | 93 |
use vars qw/@A @B/; |
... | ... | |
167 | 149 |
} |
168 | 150 |
|
169 | 151 |
1; |
152 |
|
|
153 |
__END__ |
|
154 |
|
|
155 |
=head1 NAME |
|
156 |
|
|
157 |
SL::MoreCommon.pm - helper functions |
|
158 |
|
|
159 |
=head1 DESCRIPTION |
|
160 |
|
|
161 |
this is a collection of helper functions used in Lx-Office. |
|
162 |
Most of them are either obvious or too obscure to care about unless you really have to. |
|
163 |
The exceptions are documented here. |
|
164 |
|
|
165 |
=head2 FUNCTIONS |
|
166 |
|
|
167 |
=over 4 |
|
168 |
|
|
169 |
=item save_form |
|
170 |
=item restore_form |
|
171 |
|
|
172 |
A lot of the old sql-ledger routines are strictly procedural. They search for params in the $form object, do stuff with it, and return a status code. |
|
173 |
|
|
174 |
Once in a while you'll want something from such a function without altering $form. Yeah, you could rewrite the routine from scratch... not. Just save you form, execute the routine, grab your results, and restore the previous form while you curse at the original design. |
|
175 |
|
|
176 |
=item cross BLOCK ARRAY ARRAY |
|
177 |
|
|
178 |
Evaluates BLOCK for each combination of elements in ARRAY1 and ARRAY2 |
|
179 |
and returns a new list consisting of BLOCK's return values. |
|
180 |
The two elements are set to $a and $b. |
|
181 |
Note that those two are aliases to the original value so changing them |
|
182 |
will modify the input arrays. |
|
183 |
|
|
184 |
# append each to each |
|
185 |
@a = qw/a b c/; |
|
186 |
@b = qw/1 2 3/; |
|
187 |
@x = cross { "$a$b" } @a, @b; |
|
188 |
# returns a1, a2, a3, b1, b2, b3, c1, c2, c3 |
|
189 |
|
|
190 |
As cross expects an array but returns a list it is not directly chainable |
|
191 |
at the moment. This will be corrected in the future. |
|
192 |
|
|
193 |
=back |
|
194 |
|
|
195 |
=cut |
Auch abrufbar als: Unified diff
Dokumentation einheitlich in den Footer verschoben, Datei mit END abgeschlossen (beschleunigt parsen), und POD Fehler gefixt.