open ADDLIST, "addlist" or die "can't open file: $!"; @names = ; open NEWLIST, ">>emailist" or die "can't open file: $!"; foreach (@names) { if ( $_ =~ /([^\s\@]{1,}\@[^\s\@]{1,})/) { print NEWLIST $_; } }