sub lexer { (*_) = @_; print $1 if m/\G(A)/gc || m/\G(B)/gc ; } my $a = "AB"; lexer \$a; ; lexer \$a;