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

Daniel Pittman daniel at rimspace.net
Fri Sep 11 18:55:22 PDT 2009

Sam Watkins <sam at nipl.net> writes:
> 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.

My experience is that for small data it probably won't be practically slower.

> 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.

I would advise either Text::Balanced, or a real parser, for processing the
IMAP response.

✣ Daniel Pittman            ✉ daniel at rimspace.net            ☎ +61 401 155 707
               ♽ made with 100 percent post-consumer electrons
   Looking for work?  Love Perl?  In Melbourne, Australia?  We are hiring.

More information about the Melbourne-pm mailing list