Re: [PATCH] git-svn: handle leading/trailing whitespace from svnsync revprops
- From
Björn Steinbrink <b.steinbrink@gmx.de>
- Date
- Jan 12, 2008, 09:55 UTC
- Message-ID
- <20080112095505.GA5681@atjola.homenet>
- In-Reply-To
- <20080112091242.GA27109@soma>
On 2008.01.12 01:12:42 -0800, Eric Wong wrote:
Show 21 quoted lines
> Junio C Hamano <gitster@pobox.com> wrote:
> > Is it only me who finds that
> >
> > ($var) = ($var =~ m{^(any regexp)$}) or die "message"
> >
> > is extremely a roundabout and hard-to-read way to say:
> >
> > if ($var !~ m{^(the same regexp)$} {
> > die "message";
> > }
> >
> > which is much easier to read?
>
> The statements are not equivalent, however. I'd have to add
>
> $var = $1;
>
> too, because I needed to extract what was inside the ( ) since the '$'
> doesn't catch the trailing newline, either. I also couldn't find any of
> the /sm, /m, /s switches useful for making '$' not accept the trailing
> newline, either.The \z assertion will do, eg m/^foo\z/ will only match exactly "foo", not "foo\n". As it is a zero-width assertion, you can also write m/^foo\z$/ if you prefer that.
Björn