in reply to Manipulating the Capture(s) of Regular Expressions

I'd write that as:
$text =~ s{cow\s+\K(\w+)(?=\s+over)} {do_action($1); calculate_new_action($1)}e;