I have a program that I need to do some matching in. For example, I need to match the lexemes in a LISP function and print the token out to a file. For example:

if ($input =~ /(^\()/)
{
print OUTPUT "OPAREN $1\n";
$input =~ s/^\(//;
}

I need the matching for the parentheses, letters, digits, etc. I am confused when it comes to matching. Thanks for any input you may have.