@@ -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-
679662sub _random_from_class {
680663 my ($self , $class ) = @_ ;
681664
0 commit comments