Hi all,

I am trying to use recursive regular expression in Perl.

I am using an example from http://www.perl.com/pub/a/2003/06/06/regexps.html.

Whenever I try to execute the program, it hangs and I have to do a CNTRL-C
to break it.

Please let me know where I am wrong.

*# cat t_r.pl*
#! /usr/bin/perl

use warnings;
use strict;

my $paren = qr/ \( [^)]+ \) /x;

"Some (parenthesized) text" =~ /($paren)/;
print $1; # parenthesized

    $paren = qr/
      \(
        (
           [^()]+  # Not parens
         |
           (??{ $paren })  # Another balanced group (not interpolated yet)
        )+?
      \)
    /x;

print "\n";

"Some (parenthesised and (gratuitously) sub-parenthesised text" =~
/($paren)/;
print $1; # parenthesized

print "\n";

*# perl t_r.pl*
(parenthesized)
<<Control-Break>>
*# perl -v*

This is perl, v5.8.5 built for i386-linux-thread-multi

Copyright 1987-2004, Larry Wall

Perl may be copied only under the terms of either the Artistic License or
the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.

*#*

Reply via email to