in reply to functions inside patterns

The pattern is given double-quotish interpolation (unless single quotes are the delimiter), so you can interpolate functions in a pattern the same as you would in a double quoted string --- ie, as per this faq. For example:

$_ = 'this is foo here'; sub foo {return 'foo'} print "Yup\n" if m/@{[foo()]}/; print "Yup\n" if m/${\(foo())}/;

However, while this answers your question (I think), it isn't necessarily the best thing to be doing (and be careful with context).