On Mon, Jul 01, 2002 at 10:54:26AM +0100, Mark Fowler wrote:
> So...I've got this tight loop where I need to whip a single character out
> of a ten char long string.  Now this is Perl, so there's more than one way
> to do it, unpack and substr.  Which is faster?

I would've immediately thought substr -- it is presumably just a
wrapper over the C library substr(2) which really doesn't do very much
at all. On the other hand, unpack has to parse its template and
presumably do some kind of state machine type stuff. That sounds to me
much more involved than running a pointer over a bit of memory.

Those more (er, "at all") familiar with perl sources could comment more
knowledgably I suspect...

Paul

-- 
Paul Makepeace ....................................... http://paulm.com/

"If we were a fashionable pink, then I would hug ya."
   -- http://paulm.com/toys/surrealism/

Reply via email to