in reply to search a particular file

I think you are confusing UNIX/Linux shell pattern matching with Perl. Perl uses Extended Regular Expressions for its pattern matching, it only uses shell patterns for filename expansions (globbing). Your if statement should be something like this:
if ($test =~ /^dump.*txt$/) { ... }
Notice, lower case if with the condition in parentheses.
Update: corrected RE