Put pattern in a $pat variable
Add some comments and be a little more careful about quoting