Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Updated. Fixed based on the error GrandFather was kind enough to point out.

This reminds me of a discussion of the very thing from one of the newsgroups. It was almost certainly comp.lang.perl.misc in which it took place, about a decade ago. It included silly benchmarks. Yes, we're talking premature optimization of a simple line or two not likely to be a critical point and all that. I seem to remember that s/^\s.*//; s/\s.*$//; s/^\s*//; s/\s*$//; both did very well in the benchmarks and was accepted pretty well as clear over clever. It beat out things involving extra interpolations, substr, etc.

Now, let me leverage Google Groups to refresh my memory and see if the above conclusion I recall was right. It might be interesting (although still somewhat silly) to see how the benchmarks compare on more modern perls compared to what we had then.

Here's one such: NEED: Fast, Fast string trim(). Here's another: Removing spaces in a string. It turns out there are several such threads in the newsgroup on this topic between 1996 and 2002, with some later than that. Moreover, more than one went so far as to include benchmarks.

This obviously doesn't prove the strange ones ever made it into larger projects, but given there were proponents for strange constructions there's a chance.


In reply to Re: trimming space from both sides of a string by mr_mischief
in thread trimming space from both sides of a string by szabgab

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-24 11:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found