use warnings; use strict; 'foo' =~ /(?'name'(?=o)(\w+))(?{print $+{name}})/;