File tree Expand file tree Collapse file tree 2 files changed +49
-2
lines changed
Expand file tree Collapse file tree 2 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -141,7 +141,28 @@ than brute force, but may not handle all edge cases.
141141
142142## generate\_ many($count, $unique)
143143
144- Generate a number of (possibly) unique strings for the regex
144+ Generates multiple random strings matching the regex.
145+
146+ my @strings = $gen->generate_many(10); # 10 strings (may have duplicates)
147+ my @strings = $gen->generate_many(10, 1); # 10 unique strings
148+ my @strings = $gen->generate_many(10, 'unique'); # 10 unique strings
149+
150+ # Generate until you have 1000 unique codes
151+ my $gen = Data::Random::String::Matches->new(qr/[A-Z]{3}\d{4}/);
152+ my @codes = $gen->generate_many(1000, 'unique');
153+
154+ Parameters:
155+
156+ - ` $count ` - Number of strings to generate (required, must be positive)
157+ - ` $unique ` - If true, ensures all generated strings are unique. May return fewer
158+ than ` $count ` strings if uniqueness cannot be achieved within reasonable attempts.
159+ Accepts any true value (1, 'unique', etc.)
160+
161+ Returns: List of generated strings
162+
163+ Dies: If count is not a positive integer
164+
165+ Warns: If unable to generate the requested number of unique strings
145166
146167## create\_ random\_ string
147168
Original file line number Diff line number Diff line change @@ -296,7 +296,33 @@ sub generate_smart {
296296
297297=head2 generate_many($count, $unique)
298298
299- Generate a number of (possibly) unique strings for the regex
299+ Generates multiple random strings matching the regex.
300+
301+ my @strings = $gen->generate_many(10); # 10 strings (may have duplicates)
302+ my @strings = $gen->generate_many(10, 1); # 10 unique strings
303+ my @strings = $gen->generate_many(10, 'unique'); # 10 unique strings
304+
305+ # Generate until you have 1000 unique codes
306+ my $gen = Data::Random::String::Matches->new(qr/[A-Z]{3}\d{4}/);
307+ my @codes = $gen->generate_many(1000, 'unique');
308+
309+ Parameters:
310+
311+ =over 4
312+
313+ =item * C<$count > - Number of strings to generate (required, must be positive)
314+
315+ =item * C<$unique > - If true, ensures all generated strings are unique. May return fewer
316+ than C<$count > strings if uniqueness cannot be achieved within reasonable attempts.
317+ Accepts any true value (1, 'unique', etc.)
318+
319+ =back
320+
321+ Returns: List of generated strings
322+
323+ Dies: If count is not a positive integer
324+
325+ Warns: If unable to generate the requested number of unique strings
300326
301327=cut
302328
You can’t perform that action at this time.
0 commit comments