Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^2: cut vs split (and on usefullness of cat, too:-))

by Mabooka-Mabooka (Sexton)
on Apr 18, 2005 at 16:13 UTC ( #448932=note: print w/replies, xml ) Need Help??

in reply to Re: cut vs split (suggestions)
in thread cut vs split (suggestions)

I am Perl-illiterate, but:

how is 5 faster than 1?
And how possibly "index" / "substring" could be faster than smth. like:
char* cut(char* pStr, int col, char* delim=",") { // not a real-life code, all good assumptions here: int n = 0; while(*pStr++){ if(*pStr==*delim){ if(++n == col){ return until_next_one(++pStr, delim); } } } }
Sorry if I missed the point.

Replies are listed 'Best First'.
Re^3: cut vs split (and on usefullness of cat, too:-))
by cees (Curate) on Apr 18, 2005 at 17:52 UTC

    I wasn't implying that my perl version was faster than the C version. I think it is save to say that for every perl program, there is a C program that can perform the same task in less time.

    I was stating that using index and substr where you can is almost always faster than using a regexp, so my index and substr version was faster than the join and split versions listed above. So I was comparing different perl implementations.

    I guess I probably should have timed one of the split/join examples and included that, but I didn't know which one was the fastest. So I included the timing based on the C version of cut, which gives a baseline for anyone to compare against.

    - Cees

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://448932]
[Your Mother]: Yep. Publish or die. Content be damned.
[Your Mother]: Comfort food and diabetes for the soul.
[LanX]: talking about comic adaptions ... I really liked the Watchmen
[LanX]: look I can give you a long list of excellent US movies
[Your Mother]: I adored the comic and the movie was almost a frame for frame remake (excepting the plot liberties to shorten it) but I still didn't quite like it. What's his nose, Jamie Earl whoever was flawless though.
LanX though probably produced outside Holywood
[Your Mother]: There are tons of good movies from all over but for every gem there is a pile of dirt 10 meters high burying it.
[LanX]: well
[LanX]: who's Jamie Earl?
[Your Mother]: Also: I am old and complaining is my hobby.

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (14)
As of 2018-03-19 15:00 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (240 votes). Check out past polls.