Hi,

I'm trying to make the following code works but I don't know how...

-----------------------------------------------------
def mygrep( exp )
  ar = [ "element1", "element2" ]
  ar.grep( exp ) { |e|
    # works...
    print "grep: #$&\n"
    yield e
  }
end

mygrep( /(.*)/ ) { |e|
  # doesn't work...
  print "mygrep: #$&\n"
}

-----------------------------------------------------

Displaying $& in the inner loop of grep works fine, but when it enter my own
block, $& is put back to nil. Is there a way to keep the value of $& (and
all others $1...)?

Thankx,
Ben.