$regexp = qr/(\d+)/; while ($line=~/$regexp/g) { print "number $1 found\n"; }