in reply to Regular expressions

You're only checking if there's at least one character matching your character class anywhere in your input. Anchor your regex: $temp2 =~ m/\A[a-zA-Z]+\z/. Read perldoc perleretut and perldoc perlre.

And remember to use <code></code> tags next time.