in reply to Regexp syntax nuance question, storing $1 (code)

The regex will first get $1 and any other variables interpolated, so you don't need to store it someplace else, or do anything special to it to get Perl to recognize it.

However, the code is slightly flawed. YAPE::Regex::Explain will tell you that /(a|b)+/ does not match as /a+|b+/, but rather, it matches like /[ab]+/, and stores the LAST character matched into $1. This is because the regex code looks like:
1. OPEN 1 2. MATCH 'a' OR 'b' 3. CLOSE 1 4. TRY GOTO 1
So it can match lines like "#=#=#=#=#". Icky, no? Sadly, to get the regex to work like you'd expect, you have to do something like:
sub zapwrap { my ($this, $next) = @_; return $this =~ m{ ^ \# # '#' at the beginning of the string ( [\#=] ) # a '#' or an '=' (saved to $1) \1* # that character 0 or more times $ # end of line }x and $next =~ m{ ^ # beginning of string $1+ # that character 1 or more times $ # end of string }x; }


japhy -- Perl and Regex Hacker