Skip to content

Commit 6d2dfde

Browse files
committed
Remove unused routine
1 parent 641bb70 commit 6d2dfde

File tree

2 files changed

+6
-22
lines changed

2 files changed

+6
-22
lines changed

lib/Data/Random/String/Matches.pm

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Data::Random::String::Matches - Generate random strings matching a regex
1919
2020
use Data::Random::String::Matches;
2121
22-
# Create generator with regex and optional length
22+
# Create a generator with regex and optional length
2323
my $gen = Data::Random::String::Matches->new(qr/[A-Z]{3}\d{4}/, 7);
2424
2525
# Generate a matching string
@@ -306,9 +306,9 @@ sub _build_from_pattern {
306306
# Handle (?^:...), (?i:...), (?-i:...) etc
307307
$pattern =~ s/^\(\?\^?[iumsx-]*:(.*)\)$/$1/;
308308

309-
# Remove anchors but note them
310-
my $has_start_anchor = ($pattern =~ s/^\^//);
311-
my $has_end_anchor = ($pattern =~ s/\$$//);
309+
# Remove anchors (they're handled by the regex match itself)
310+
$pattern =~ s/^\^//;
311+
$pattern =~ s/\$//;
312312

313313
return $self->_parse_sequence($pattern);
314314
}
@@ -539,6 +539,7 @@ sub _handle_quantifier {
539539

540540
if ($next eq '{') {
541541
my $end = index($pattern, '}', $pos + 1);
542+
croak "Unmatched '}'" if ($end == -1);
542543
my $quant = substr($pattern, $pos + 2, $end - $pos - 2);
543544

544545
# Check for possessive after }
@@ -658,24 +659,6 @@ sub _find_matching_paren {
658659
return -1;
659660
}
660661

661-
sub _find_matching_curly_bracket {
662-
my ($self, $pattern, $start) = @_;
663-
664-
my $depth = 0;
665-
for (my $i = $start; $i < length($pattern); $i++) {
666-
my $char = substr($pattern, $i, 1);
667-
my $prev = $i > 0 ? substr($pattern, $i-1, 1) : '';
668-
669-
if ($char eq '{' && $prev ne '\\') {
670-
$depth++;
671-
} elsif ($char eq '}' && $prev ne '\\') {
672-
$depth--;
673-
return $i if $depth == 0;
674-
}
675-
}
676-
return -1;
677-
}
678-
679662
sub _random_from_class {
680663
my ($self, $class) = @_;
681664

t/40-advanced.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ subtest 'Mixed features' => sub {
184184
# Alternation with backreferences
185185
my $gen1 = Data::Random::String::Matches->new(qr/(cat|dog)-\1/);
186186
my $str1 = $gen1->generate_smart();
187+
187188
like($str1, qr/^(cat|dog)-\1$/, 'Alternation with backreference');
188189
ok($str1 eq 'cat-cat' || $str1 eq 'dog-dog', 'Correct repetition');
189190

0 commit comments

Comments
 (0)