
mhx
Enthusiast
Sep 30, 2001, 8:06 AM
Post #4 of 5
(17407 views)
|
Re: using variable to select for match length
[In reply to]
|
Can't Post
|
|
1) Perl 5.005_03 would not run the code. Perl 5.6.0 had no problem. Which version of Perl were you using? I'm using 5.6.0, 5.6.1 and 5.7.2. I've tested the code with 5.6.0. Perl 5.6.0 introduced some new (experimental) regex features, two of which are (?{...}) and (??{...}). So this won't work with any version older than 5.6.0.
2) I'm writing a report parser. The number of records in the report appears at the top of the report. I thought it would be great if I could check the real number of records against the record number at the top of the report ALL from within a single regexp. Ultimately, when I placed the more complicated record regexp in the (??{}) expression the match failed. The record regexp has things like \s* and grouped expressions like (a|b|c)... Sorry, I don't really get it. Perhaps you could post the source data and the regex (or even a greater code snippet) you're trying to use.
I've been trying to sort of "factor out" the a expression as I think it would make your technique more powerful. I've tried things like: (\d+)a(??{"{$1}"}) (\d+)a{(??{"$1"})} If there was a way to evaluate just the part inside the brackets which actually denotes the multiplier then we'd have it... so close. There's no such way to dynamically insert a repetition count. Only complete regexes can be inserted dynamically, like I did in my last post. I don't know how familiar you are with regular expressions, but perhaps you find some debug output of the regex engine useful while playing around with regexes. Just insert on top of your script and you will see lots of additional information about the regexes you're using. Hope this helps. -- Marcus
s$$ab21b8d15c3d97bd6317286d$;$"=547269736;split'i',join$,,map{chr(($*+= ($">>=1)&1?-hex:hex)+0140)}/./g;$"=chr$";s;.;\u$&;for@_[0,2];print"@_,"
|