in reply to variables from STDIN

I don't know what you mean by a "first a", or a "second a". How do you distinguish between them?
my $a1 = "a"; # Does it matter "which" 'a' this is? my $a2 = "a"; my $a4 = "a"; my $b1 = "b";
Perhaps you mean something else. Could you reformulate your question?