while ( $x =~ m{^ (?A|B) (?.+) $}xmg ) { print "$+{name} method1 $+{data}\n" }