set $~ to match array in String#sub, convert undefined values to nil