[Melbourne-pm] Extracting a parenthesized fragment from a string

Timothy S. Nelson wayland at wayland.id.au
Fri Sep 11 18:58:42 PDT 2009

On Fri, 11 Sep 2009, Sam Watkins wrote:

> On Fri, Sep 11, 2009 at 07:05:45PM +1000, Robert Norris wrote:
>> So, what's wrong here? And is there an easier way to do this? Note that
>> I'm restricted to Perl 5.6, which sucks as I'd really like to try the
>> PARNO stuff that came with 5.10.
> I think normal regexps aren't the right tool for this, you can do it
> easily in a couple of lines of C, but that method would be somewhat slow
> in perl.  But given that you're dealing with IMAP, the network is going
> to be a lot slower, so you might as well just do it with a for loop over
> the characters and count parentheses, rather than some totally obscure
> regexp hack.

 	Incidentally, this is something that Perl 6 will solve.  Because it 
has grammars.  You could use Parse::RecDescent and an IMAP grammar, but that 
would be overkill in a P5 situation.  P6 on the other hand... :).

| Name: Tim Nelson                 | Because the Creator is,        |
| E-mail: wayland at wayland.id.au    | I am                           |

Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- 
PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y-

More information about the Melbourne-pm mailing list