Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

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

What part of "If it really bothers you just add one line to your code and be done with it." would indicate I'm against abstraction rather than the introducing an external dependency on a CPAN module that hasn't been updated in over a year which provides a bunch of marginally "string" related subs that are pretty much all wrappers for around 3-4 lines worth of code?

sub trim { (my $t = shift()) = s/^\s+//; $t =~ s/\s+$//; $t }

There, done. Add that to your stock program template or define it as a snippet in your editor and Robert is your parent's sibling.

(Having said that, yes I do have issues to some degree with this level of micoabstraction. Does the putative trim work on just one string, or a list of strings (a la chomp)? If the string contains multiple lines, does it remove spaces from the absolute beginning and end of the string or from the beginning and end of the logical lines? It's easy to tell the difference when s/^\s+// versus s/^\s+//mg (and their corresponding $ anchored cohort) are sitting there in front of you; it's not when you've got to break your train of thought and spend 3-5 minutes API diving. Two lines just seems waaaaaay below the threshold of worth-abstracting-ness.)


In reply to Re^4: Pulling white space off before/after string? by Fletch
in thread Pulling white space off before/after string? by ecuguru

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 rifling through the Monastery: (6)
As of 2024-04-18 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found