[comp.lang.perl] m//g problem in 4.009

tchrist@convex.COM (Tom Christiansen) (06/09/91)

According to the documentation, this should work, but doesn't:

	while (<>) { @words{/\w+/g} = (); }
	print join("\n", sort keys %words), "\n";

Changing the while's statement to 
	
	@words = /\w+/g;
	@words{@words} = ();

doesn't help either.

It looks like it's not recognizing to reset where to 
start looking after each //g when in an array context
(it's not supposed to in a scalar one.)

Sadly, this doesn't work either:

    while (<>) { while (/(\w+)/g) { $words{$1}++; } }

So I think that either I just don't know how this guy's 
supposed to work, or else it doesn't.

All the self-tests passed.  I suggest adding some multi-line 
tests to t/op/pat.t in the test suite to check for this.

And another thing: under the debugger, "p /\w+/g" yields:

"\nNULL regexp parameter at (eval) line 1, <> line 2.\n\n\n DB< 2 >\n";

(Yes, there are lotsa newlines there.)

And "p /\w+/g" dumps core.


--tom
--
Tom Christiansen		tchrist@convex.com	convex!tchrist
		"So much mail, so little time."