Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Efficient walk/iterate along a string

by GrandFather (Sage)
on Nov 23, 2010 at 01:02 UTC ( #873089=note: print w/replies, xml ) Need Help??

in reply to Efficient walk/iterate along a string

Perl is a tool that handles complicated string manipulations well, but it's not designed to handle individual characters near so well. For that you need something closer to the silicon like C. However, on a case by case basis it may be that you don't need to handle individual characters and instead can use index or a regex to do much of the heavy lifting. The alternative may be to invest the time in writing an XS module that provides an iterator to efficiently traverse a string returning a character at a time and providing the current index on demand.

True laziness is hard work
  • Comment on Re: Efficient walk/iterate along a string

Replies are listed 'Best First'.
Re^2: Efficient walk/iterate along a string
by DrHyde (Prior) on Nov 23, 2010 at 10:22 UTC
    Please do this - I've occasionally had to solve similar problems, and thought "this is where perl needs pointers", but never had the tuits to actually implement it.

      I suspect that if there was a real need for this and an XS solution does actually provide substantial speed gains over substr or the reverse and chop trick then it'd have already been done.

      Most times a smarter algorithm gives much more bang for the buck than tinkering with an implementation to make the old algorithm a little faster.

      True laziness is hard work

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://873089]
[stevieb]: Marshall: no. I commented on the thread yesterday. Visual Studio updates the tags ok, but corrupts the exe
[stevieb]: I advised the OP that a possible workaround would be to add a version function/flag that displays the required copyright/license info instead
[Marshall]: Darn! I'll look at the thread. Must not be updatinga byte count somewhere. The .exe format is a complex critter.
[stevieb]: that way, it's still "hard coded" into the exe at least, despite not being visible via Properties
[Marshall]: I also looked into PerlApp from Active State, but they don't sell their Dev Kit independent of a very expensive ($1,200) per year license anymore.
[Corion]: I would assume that the PE format hasn't changed that much since the days of yore, but it seems that I would be wrong in that assumption
[Marshall]: When I bought my copy 15+ years ago, it was just a couple hundred bucks.
[Marshall]: I looked at MS specs for PE format and I didn't see any changes in last decade, but evidenly that would be wrong.

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2016-12-08 18:18 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (144 votes). Check out past polls.