my @email = ; close OPENFILE; my $count; foreach my $email (@email){ if ($email =~ /mailto:/) { $count += 1; } print $count; # error here }