sub xxx { my $query = CGI->new; my $mail = CGI->new; my @recipient = (); open(my $file, "<", "users.txt") or die "Can't open input.txt: $!"; my $hotmail = "hotmail\.com"; my $gmail = "gmail\.com"; # print $query->header('text/html'); # create the HTTP header # print $query->start_html('Login Access'); # start the HTML while (<$file>) { chomp; my $emailid= (split/\s+/,$_) [2]; if (/$hotmail/) { push(@recipient,$emailid); } elsif (/$gmail/) { push(@recipient,$emailid); } } $email = join(', ', @recipient); return $email; }