http://qs321.pair.com?node_id=1230882


in reply to Regex backreference without capture

Hi

? So you want  @x = qw( first third ) ;

This "works"

dd( 'bogus firstblahjokeblahthird bogus' =~ m/ (first) (?&patblah) .*? (?&patblah) (third) (?(DEFINE) (?<patblah>blah) ) /sx ); __END__ ("first", "third", undef)

The undef comes from the named capture  (?<patblah>blah) which takes up slot $3 in this pattern, which is why (?(DEFINE) is placed at the end