Thread (3 messages) flat view 3 messages, 3 authors, 2016-06-15

Re: [PATCH] git-svn: handle leading/trailing whitespace from svnsync revprops

From: Björn Steinbrink <hidden>
Date: 2016-06-15 22:44:04

On 2008.01.12 01:12:42 -0800, Eric Wong wrote:
Junio C Hamano [off-list ref] wrote:
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help