Thanks for the reply Kanji.
I've restructured my code as you advise, however, and this is why I was using the 'no strict "subs"' clause (although the context in my original post didn't make sense), I get an error on compilation.
Here's the code snippet -
if ($os_type eq "NT") {
require Win32::EventLog;
import Win32::EventLog qw / :DEFAULT /;
my $eventlog_type;
if ($priority ne "info") {
$eventlog_type = EVENTLOG_WARNING_TYPE;
} else {
$eventlog_type = EVENTLOG_INFORMATION_TYPE;
}
$eventlog->Report({
EventType => $eventlog_type,
Strings => $message,
});
}
This generates the errors -
Bareword "EVENTLOG_WARNING_TYPE" not allowed while "strict subs" in us
+e at scriptname line 2007.
Bareword "EVENTLOG_INFORMATION_TYPE" not allowed while "strict subs" i
+n use at scriptname line 2010.
If I prefix the exported variables with Win32::EventLog, I get the same error. It's just struck me that this may be a problem with Win32::EventLog itself - I can see in EventLog.pm where the variables are exported, but I can't see where they're declared.... hmmmm.
Pete
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.