open my $fh, '<', 'theFile' or die $!; my $count = 0; while( <$fh> ) { ++$count while m[the]g; } print "'the' appeared $count times in 'theFile'"; #### if( $extract =~/^\( (\d.+) \)$/ ) { print "The number was $1"; } else { print "The regex didn't match"; }