Chance Ervin [mailto:[EMAIL PROTECTED] 
: 
: 
: 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.
: 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";

    Close only takes 1 argument.

    Try:

close LOGFILE or die "Cannot close $opt_f: $!";

    Or:

close (LOGFILE) || die "Cannot close $opt_f: $!";
 
    If you leave the "\n" off after $! perl will tell you
the line number of the error as well.


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328


-- 
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