in reply to Re^2: Checking number in file name
in thread Checking number in file name

Splitting is probably better for you than using a regex. Especially if you later want to do something with the other parts of the filename, too.

my ( $accountnumber, $part2, $part3, $part4, $part5, $extension ) = sp +lit /[_.]/, $filename;