I have modified my code $action is set to the email address and it is then set back to 'No' to start the loop again,
if(/^Subject:/ && $action eq 'Yes')
{
$myvar = $_;
$myvar =~ s/: /: !SPAM!/g;
print $myvar;
$action = 'No';
}
if(/^From:\s([0-9a-zA-Z\.\-\_]{13,})+\@[0-9a-zA-Z\.\-]+$/)
{...