From: Dave Thomas Date: 2003-05-24T13:42:38+09:00 Subject: Re: why is "does" missing from this sub!-stitution? dblack@superlink.net wrote: > I'm with you on the 'what', but I'm still curious about the 'why'. > It's true that the replacement string gets parsed before sub is > called. But I think "abcdef" gets matched against the regex even > before that parse happens. But it doesn't. Think about it this way def fred(a, b) $x = 1 puts a puts b end $x = 99 fred(11, $x) fred(11, $x) #=> 11 99 11 1 The parameters to a method are evaluated at the point of call: the method can't affect the value of its parameters. Which means... if the $1,$2 variables > reflect the results of the most recent match, then one could argue > that by the time the replacement string is parsed, a match has just > taken place and $1,$2 should reflect the results of that match. .sub is just a method, so it can't affect the value of its second parameter. Cheers Dave