using a correct regular expression, e.g. if ($file =~ m/AAAA\*.*?$date/) { ... }Update: Missed, that there is a literal * in the filename. \$ matches literal $, not $date.
Non-greedy matching is probably not necessary here, but does no harm (in response to question below). It would be a good idea to also anchor the regexp.