http://qs1969.pair.com?node_id=129711


in reply to Re: Coding for two platforms in one Script
in thread Coding for two platforms in one Script

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

Replies are listed 'Best First'.
Re: Re: Re: Coding for two platforms in one Script
by buckaduck (Chaplain) on Dec 06, 2001 at 01:16 UTC
    The constants EVENTLOG_* are not grouped into an export group called ":DEFAULT". It looks like you'll have to ask for each one that you want:
    require Win32::EventLog; import Win32::EventLog qw / EVENTLOG_WARNING_TYPE EVENTLOG_INFORMATION +_TYPE /;

    buckaduck