I am trying to open a file, and read the contents, but every execution gives
me an error:

cannot open filename: Bad file number

Below is the program as it stands now. I am guessing that I have a trailing
something causing the issue, but I can't seem to put my finger on it.

Thanks for the help.
============================================================================
================================

use Mail::Mailer;

use Getopt::Std;
getopt("f:");

my $mailflag=1;
my $host=`hostname`;
my @log_content;


die "Usage: $0 -f filename\n"
    if (!defined $opt_f);

chomp($opt_f);

my $mailer = Mail::Mailer->new();
my $from_address = 'check_log@' . $host;
my $to_address = '[EMAIL PROTECTED]';
my $subject =  $host . ": " . "Log Scan - " . $opt_f;

open(LOGFILE, "$opt_f") || die "cannot open $opt_f: $!\n";
while (<LOGFILE>) {
   push (@log_content, $_);
}
close (LOGFILE, "$opt_f") || die "cannot open $opt_f: $!\n";


if ($mailflag eq 1) {
      $mailer->open({ From    => $from_address,
                      To      => $to_address,
                      Subject => $subject,
                    })
      or die "Cannot open: $!\n";
      print $mailer @log_content;
      $mailer->close();
}

-----------------------------
InteleNet Communications Inc.           "Help me help you."
Chance Ervin - SCSA                     --Jerry Maguire
Oracle Certified Professional
Supervisor of Network Operations




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to