open (FILE '); close (); my ($result) = m!$match(?:.*?$/){$Nth}(.*?$/)!s; print $result; #### open (FILE '); while ( m!$match(?:.*?$/){$Nth}(.*?$/)!sg) { print $1; # pos = length ($match) + length ($`); }