open (MYFILE, 'RegExTest.txt'); #Init variables $searchTerm = "searchForThis"; $pre = "NotBefore"; $post = "NotAfter"; #Loop through the file while () { $line = $_; if($line =~ m/(?