trying to follow some modules examples.. but have a quick quesiton

Below pm works if I don't use strict and use @ISA and @EXPORT.. but not
when I use strict and my @ISA and my @EXPORT........

am i not suppose to use strict for modules??

--------------- only works...... ------------------------
use strict;
use warnings;


package BOA::Logger;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(open_log log_level write_log);

my $LOG_LEVEL = 1; # default log level is 1

#open log file
#
sub open_log {
     my $filename = shift;
     open 'LOG_FILE', ">>$filename" or die "Unable to open $filename : $!";
     print LOG_FILE "BOA log strated: " . localtime(time) . "\n";
}

#set logging level
sub log_level { $LOG_LEVEL = shift; }

#write a log message if level is set high enough
sub write_log {
     my ($level, $message) = @_;
     print LOG_FILE "$message\n" if $level <= $LOG_LEVEL;
}

1;

--------- if I have above w/ my and strict, it won't work -----------------

[EMAIL PROTECTED] tmp]# ./useboa.pl
Global symbol "@ISA" requires explicit package name at /tmp/cpan_pratice/BOA/Logger.pm line 24. Global symbol "@EXPORT" requires explicit package name at /tmp/cpan_pratice/BOA/Logger.pm line 25.
Compilation failed in require at ./useboa.pl line 25.
BEGIN failed--compilation aborted at ./useboa.pl line 25.



-------------------------------------------------------------------------------
#useboa.pl
use strict;
use warnings;

use lib '/tmp/cpan_pratice';
use BOA::Logger;

#open the log file
#BOA::Logger::open_log("logs/boa.log");
open_log("logs/boa.log");

#set the log level higher
#BOA::Logger::log_level(10);
log_level(10);

#write a log entry at level 5
#BOA::Logger::write_log(5, "Hello log reader.");
write_log(5, "Hello log reader.");

#write a log entry at level 15 - this won't be printed to the log
#BOA::Logger::write_log(15, "Debugging data here.");
write_log(15, "Debugging data here.");

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


Reply via email to