You need a regular expression in your if-test. Start by doing:
at a command prompt. You'll notice if you page down a little that there are these 2 perldocs listed for regular expressions:
perlre Perl regular expressions, the rest of the story
perlreref Perl regular expressions quick reference
So, if you want to read the 1st one, you would do
at a command prompt. The 1st response to your question gave you a regular expression to try. Read the perldocs, try a regular expression, and post back if you still have problems.