my $regexp = qr/(\d+)\s+(\d+)/; while(<$fh>) { next unless /$regexp/; my $value1 = $1; my $value2 = $2; print "GOT $value1 $value2\n"; }