I wrote this perl sript and it should move the file
to the other directory after the mail was sent.
I get this error message:
"Useless use of string in void context at mail.cgi line 75.
Can't call method "move" without a package or object reference at mail.cgi line 75."
knows someone what's wrong and how to correct it?
#!/usr/bin/perl -w
use strict;
use warnings;
my $recipient = "recipient\@mydomain.net";
my $linux = "root\@mydomain.net";
my $file = "/var/tmp/file.txt";# read the file
my $content;
open(FILE, $file) ¦¦ die "Cant open file. Reason: $!"; # (-:
while(<FILE>) {
$content .=$_; # get all of the file into content including past new lines
}
close(FILE);
# send the mail with file content
open(MAIL, "¦/usr/sbin/sendmail -t") ¦¦ die "Cant send mail. Reason: $!";
print MAIL "from:$linux\n";
print MAIL "to:$recipient\n";
print MAIL "subject:Hi!\n";
print MAIL "$content \n\n";
print MAIL "Time: ", scalar localtime, "\n";
close(MAIL);
#move file to the new directory and remove it at the old location
move $file, "/var/backup";
exit;