if (($ENV{QUERY_STRING} eq "new") && (-e $file)){unlink($file);} #### #!/usr/bin/perl -w use strict; my $mailprog = '/usr/lib/sendmail'; my $mail = 'recipient-email@adress.com'; my $from = 'sender-email@address.com'; my $file = 'report.txt'; my $num; if ($ENV{QUERY_STRING} ne "new" and -f $file) { open (DATA, $file); $num = ; close (DATA); $num =~ s/\D+//g; } $num ||= 0; if ( open (MAIL, "|$mailprog -t")) { print MAIL "Content-Type: text/plain; charset = windows - 1251\n"; print MAIL "Subject: Text, Text!\n"; print MAIL "To: $mail\n"; print MAIL "From: $from\n\n"; print MAIL "Hello, the message text itself..\n"; print MAIL "\n\n"; close (MAIL); $num++; } else { $num = "Unable to use $mailprog"; } if ( open (DATA, ">$file")) { print DATA $num; close (DATA); } else { my $might = ( -e $file ) ? 'does' : 'does not'; $num .= "
Unable to write to $file (it $might exist)."; } print "Content-type: text/html\n\n"; print "$num\n";