Perl filter

creates a 'g' function that essentially curries a state variable until a final tag is given.