[sf-perl] amusing bug

Garth Webb garth.webb at gmail.com
Tue May 4 13:48:31 PDT 2010


Or just match the bits you care about:

  $line =~ s/^\s+|\s+$//g;

On Tue, May 4, 2010 at 1:35 PM, Steve Fink <sphink at gmail.com> wrote:

> You might want to also make those +s into *s... (you're requiring
> lines to have whitespace on *both* sides before you'll fix 'em.)
>
> On Tue, May 4, 2010 at 1:02 PM, Joe Brenner <doom at kzsu.stanford.edu>
> wrote:
> >
> > David Alban wrote:
> >> it's so easy to miss the error in:
> >>
> >>      $line =~ s{ s+ \z }{}xms;
> >>
> >> when you expect to see:
> >>
> >>      $line =~ s{ \s+ \z }{}xms;
> >>
> >> i wondered why one of the lines was having its last character stripped
> >> but the others were ok.
> >
> > The one I like is
> >
> >   $line =~ s{ ^ \s+ (.*?) \s+ $ }{ $1 }x;
> >
> > It always takes me awhile to figure out why the leading and
> > trailing spaces aren't all going away.
> >
> > (I need a \X modifier that makes spaces insignificant in the
> > replace string as well as in the find pattern.)
> >
> > _______________________________________________
> > SanFrancisco-pm mailing list
> > SanFrancisco-pm at pm.org
> > http://mail.pm.org/mailman/listinfo/sanfrancisco-pm
> >
> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/sanfrancisco-pm/attachments/20100504/261d1445/attachment.html>


More information about the SanFrancisco-pm mailing list