while () { # assuming you want what is between the '' after version chomp($old_version) && last if ($old_version) = /ver = '(.*?)'/; } close INFILE;