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":



  • 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.