Being curious as Perl people will be, i tired an rindex based solution. It unfortunatly would only work with true spaces (" "), and did not fare too well in testing, but, we all learn when things like this happen ... here is my code/output :

Code Addition :
P_rindex => sub { my $x = $X; while (1) { my $i = length($x); (rindex($x," ") == $i ? chop : las +t) }; }, F_rindex => sub { my $x = $Y; while (1) { my $i = length($x); (rindex($x," ") == $i ? chop : las +t) }; },


Output :
Benchmark: running F_plus, F_rindex, F_sexeger, F_while, P_plus, P_rin +dex,P_sexeger, P_while, each for at least 5 CPU seconds... F_plus: 6 wallclock secs ( 5.15 usr + 0.00 sys = 5.15 CPU) @ 37 +600.97/s(n=193645) F_rindex: 6 wallclock secs ( 5.45 usr + 0.00 sys = 5.45 CPU) @ 59 +183.30/s(n=322549) F_sexeger: 7 wallclock secs ( 5.24 usr + 0.00 sys = 5.24 CPU) @ 59 +187.60/s(n=310143) F_while: 7 wallclock secs ( 5.29 usr + 0.00 sys = 5.29 CPU) @ 69 +741.02/s(n=368930) P_plus: 5 wallclock secs ( 5.46 usr + 0.00 sys = 5.46 CPU) @ 33 +136.08/s(n=180923) P_rindex: 6 wallclock secs ( 5.31 usr + 0.00 sys = 5.31 CPU) @ 60 +743.69/s(n=322549) P_sexeger: 5 wallclock secs ( 5.36 usr + 0.00 sys = 5.36 CPU) @ 49 +557.65/s(n=265629) P_while: 6 wallclock secs ( 5.09 usr + 0.00 sys = 5.09 CPU) @ 50 +179.17/s(n=255412) Rate P_plus F_plus P_sexeger P_while F_rindex F_sexeger P_ +rindex F_while P_plus 33136/s -- -12% -33% -34% -44% -44% + -45%-52% F_plus 37601/s 13% -- -24% -25% -36% -36% + -38%-46% P_sexeger 49558/s 50% 32% -- -1% -16% -16% + -18%-29% P_while 50179/s 51% 33% 1% -- -15% -15% + -17%-28% F_rindex 59183/s 79% 57% 19% 18% -- -0% + -3%-15% F_sexeger 59188/s 79% 57% 19% 18% 0% -- + -3%-15% P_rindex 60744/s 83% 62% 23% 21% 3% 3% + ---13% F_while 69741/s 110% 85% 41% 39% 18% 18% + 15%--

As usual, nothing fantastic, but worth the learning experiance.
OH, a sarcasm detector, that’s really useful

In reply to Re: japhy blabs about regexes (again) by MZSanford
in thread japhy blabs about regexes (again) by japhy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.