my ($var) = $content =~ /(.{3}\-a99\-9)/; $var = $1; #### if (not defined $var) { print "The whole name was changed so no match found. You need to change your reg expression.\n"; exit 0; #Since no match then exit the script. }