if ($ethernet=~/eth1\.\d{4}\@/m){ ## do something matches++; } }