[sf-perl] amusing bug

Steve Fink sphink at gmail.com
Tue May 4 13:35:31 PDT 2010


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
>


More information about the SanFrancisco-pm mailing list