Re: Simplest Way



Paul Lalli wrote:
>http://perldoc.perl.org/perlfaq4.html#How-do-I-strip-blank-space-from-the-beginning/end-of-a-string%3F

The perldocs are correct and fine, of course, but if you want to do it
the "Damian Conway way" (from his book, Perl Best Practices) you would
use a syntax something like:

s{\A \s* | \s* \z}{}gxm;

Or maybe

use Regexp::Common qw /whitespace/;
s/$RE{ws}{crop}//;

Damian makes a good case for these techniques... it would be wise for
coders to consider his recommendations, even though (in this sort of
situation, at least) they are a rather severe departure from
long-established practices.

New coders should especially consider Damian's recommendations, so they
don't need to struggle with un-learning old (and not so good) habits.

.



Relevant Pages