tshabet has asked for the wisdom of the Perl Monks concerning the following question:
O'Reilly notes that you can't declare the variable in the same statement where it's used, which makes sense to me. So I added the declaration above. Problem is, when I run my code I get this error:local $np; # I added this declaration myself $np = qr{ \{ (?: (?> [^{}]+ ) | (??{ $np }) )* \} }x;
The "uninitialized value" warning isn't surprising, since $np is of course uninitialized. It would seem to me that I am screwing up on correctly declaring this variable so that it can be used recursively. While trying to diagnose the problem, I set $np to various values and the error output changed to reflect this. For instance, if I declare $np = "foo"; the error becomesUse of uninitialized value at shorty.pl line 19 (#1) (W) An undefined value was used as if it were already defined. It + was interpreted as a "" or a 0, but maybe it was a mistake. To suppre +ss this warning assign an initial value to your variables. Uncaught exception from user code: / { (?: (?> [^{}]+ ) | (??{ }) )* } /: Sequence (??...) not recognized
So it would seem to me that I am screwing up good code with a bad variable declaration. O'Reilly wouldn't lead me astray, right? :-) So after scouring this and other resources for past info on similar problems, I'm finally stumped enough to announce it publicly on this forum. I am using v. 5.005_02, is it possible that the (??{ }) is not present in this version? I was unable to find much technical documentation for match time pattern interpolation. Thanks to everyone for their time and considerations.Uncaught exception from user code: / { (?: (?> [^{}]+ ) | (??{ foo }) )* } /: Sequence (??...) not recognized
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with recursive pattern matching
by Hofmator (Curate) on Jul 26, 2001 at 18:39 UTC | |
|
Re: Problem with recursive pattern matching
by Tyke (Pilgrim) on Jul 26, 2001 at 18:42 UTC | |
by converter (Priest) on Jul 26, 2001 at 19:37 UTC | |
|
Problem with recursive pattern matching
by tshabet (Beadle) on Jul 26, 2001 at 19:09 UTC |