|
Posted by bugbear on March 17, 2008, 6:20 am
Please log in for more thread options
ptilderegex wrote:
>> In article
>>
>>>> Perhaps you can list a couple of examples. People in this newsgroup
>>>> love showing others how easy it is to get things done with regular
>>>> expressions. :)
>>> A simple example: lets say that in Perl you have a regex but you don't
>>> know what it is. Its held in a string passed by some function and
>>> needs to be a parameter. Now, you want to strip everything but what
>>> matches each time. Or better yet, output what does match to one
>>> stream, and output what doesn't match to another (in one pass).
>> It sounds like most of your problem has little to do with regular
>> expressions and more to do with I/O management.
>>
>> while( <$fh> )
>> {
>> if( m/$regex/ ) { print $out "$`$'"; print $out2 $& }
>> else { print $out }
>> }
>
> The point of Ptilde is that you can do these complex stream
> transformations of any kind at all in one regex pass. What you've got
> above is a while loop, not a single regex pass.
You say that as if it's a bad thing.
BugBear
|