I was just testing out the code from the book 'writing perl modules for cpan' and I am trying out below module and getting compiled error.
I cannot/donot see what is wrong w/ the code.

can anyone see?

use strict;
use warnings;


package BOA::Logger2;
use Carp qw(croak);
use IO::File;

#constructor - returns new BOA::Logger2 objects
sub new {
   my ($pkg, $filename) = @_;

   #initialize $self as a reference to an empty hash
   my $self = {};
#open the log file and store IO::File object in $self->{fh}
   my $filehandle = IO::File->new(">>$filename");
   croak("Unable to open $filename: $!") unless $filehandle;

   #print startup line
   $filehandle->print("BOA log started: " . localtime(time) . "\n");

   #store the filehandle in $self
   $self->{fh} = $filehandle;

   #set default log_level of one
   $self->{level} = 1;

   #bless $self as an object in $pkg and return it
   bless($self, $pkg);
   return $self;
}

# level method - changes log level for this log object
sub level {
   my ($self, $level) = @_;
   $self->{level} = $level;
}

# write method - writes a line to the log file if log-level is high enough
sub  {
   my ($self, $level, $message) = @_;
   $self->{fh}->print($message) if $level <= $self->{level};
}


1;


[EMAIL PROTECTED] BOA]# perl -c !$
perl -c ./Logger2.pm
Number found where operator expected at ./Logger2.pm line 62, near "1"
       (Missing semicolon on previous line?)
syntax error at ./Logger2.pm line 62, near "1"
./Logger2.pm had compilation errors.
[EMAIL PROTECTED] BOA]#

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


Reply via email to