Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Re: Coding for two platforms in one Script

by BoredByPolitics (Scribe)
on Dec 05, 2001 at 23:14 UTC ( #129711=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://129711]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (1)
As of 2022-01-28 06:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (73 votes). Check out past polls.

    Notices?