in reply to Checking number in file name

If you want to check whether the accountnumber is part of the filename is has to be

if( $filename =~ /$accountnumber/gi ) {

and not the other way round. But it seems you have tested that already. You might want to add additional checks such as that there is not a digit before and after the account number or similar. Otherwise there could be a match if the account number is part of another number in the filename.

Also, if you are after digits only use \d not \w.