$fname = "C:\\EITV10CMD\\base\\detection\\basic\_detection\\Filename\\DOIFFILE.COM"; while () { chomp; my $found; if($_ =~ /^\Q$fname\E/i) { chomp($_); /\s*(\.){3}\s*(.*?)$/; #Trying to extract everthing after ... $found = $2; }