in reply to Regexp oddity

If you don't have the end-of-line anchor ($) in your regex in the program, $3 will contain nothing. Otherwise, it will contain " blah2".

If you make the last parenthesized match non-greedy by removing the trailing question mark, you can leave out the final $.

I recommend using a line like the following to show what you've captured, just in case you have whitespace: print "1: ->$1<-\n2: ->$2<-\n3: ->$3<-\n";