print TOHOST "To: $your_email \nFrom: $your_email\n"; print TOHOST "Subject: Name Change\n"; print TOHOST "$email_send\n"; #### print TOHOST "To: $your_email \nFrom: $your_email\n", "Subject: Name Change\n", "$email_send\n"; #### print TOHOST <## use strict; use warnings; #### $sock, $name, $match, @email, $sendmail, $your_email #### #!/usr/bin/perl use strict; use warnings; # (the code before your example here...) my $n = 50; while (1) { my $time = time(); print $sock "$name\r\n"; my @output; my $output = join( '', @output ); $| = 1; while (<$sock>) { if ( $output = /$match/ ) { my $searchlog = "searchlog.txt"; open( FILELOG, ">>$searchlog" ) || die "Can't write to '$searchlog': $!\n"; print FILELOG "$time $name\n"; close FILELOG; my $tmpl = "email.txt.asc"; my @tmpl; open( TMPL, $tmpl ) || print "Can't read '$tmpl': $!\n"; @tmpl = ; close(TMPL); my ( @email_send, $email_send ); foreach my $line (@tmpl) { $line =~ s/XnameX/$name/g; push @email, $line; $email_send = join( '', @email ); } open( TOHOST, "|$sendmail $your_email" ) || print "Can't run '$sendmail': $!\n"; print TOHOST "To: $your_email \nFrom: $your_email\n", "Subject: Name Change\n", "$email_send\n"; close(TOHOST); } else { my $log_txt = "log.txt"; open( FILELOG, ">>$log_txt" ) || die "Can't write to '$log_txt': $!\n"; print FILELOG "$time $name\n"; close FILELOG; } sleep( int( 43200 / $n ) - ( time() - $time ) ); } }