[comp.lang.perl] Long-running regexp

andrew@fgh.fgh.oz (Andrew Buchanan) (06/13/90)

	The following script causes perl to take a very, very long time:

	    ("A" x 10) =~ /^.{0,50}\s/;

	I don't think it's an infinite loop, because if I make the
	string smaller (eg 3) or the regexp repetition smaller (eg 10),
	it does complete.  In place of the \s it seems that any
	value that fails and is not constant causes the problem, e.g.
	\W, [BC] &c.

	In my original script I worked around the problem by avoiding
	the regexp altogether, but I am puzzled why it is taking so long.
	I am only slightly familiar with regexp operation, so I may be
	missing something obvious.  However, an analogous sed script
	such as

	att> echo ' :\nAAAAAAAAAA' | sed -n -e '/^.\{0,50\}[ 	]/p'
	 :
	att>
	
	completes in normal time.

	I am running

$Header: perly.c,v 3.0.1.5 90/03/27 16:20:57 lwall Locked $
Patch level: 18

	on a Pyramid 9810.  (The problem happens in both the ucb [Berkeley]
	and att [System V] compiled versions of perl).
-- 
Andrew Buchanan				| andrew@fgh.fgh.oz.au
FGH Decision Support Systems Pty Ltd	| ..!uunet!fgh.fgh.oz.au!andrew