Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Coding for two platforms in one Script

by VSarkiss (Monsignor)
on Dec 05, 2001 at 21:59 UTC ( [id://129685]=note: print w/replies, xml ) Need Help??


in reply to Coding for two platforms in one Script

I've never used autouse, but I suspect you're having problems with the fact that use happens too early. You probably need to move them to a BEGIN block (which is where use "executes"). Something like this may work:

BEGIN { if ($^O eq "MSWin32") { use Win32::EventLog qw(Report new); } else { use Sys::Syslog qw(:DEFAULT setlogsock); } } # later... if ($^O eq "MSWin32") { my $eventlog = Win32::EventLog->new("myscript"); } else { Sys::Syslog::setlogsockt ('unix'); Sys::Syslog::openlog ("myscript", 'pid', "INFO"); }
(warning, this is untested.)

HTH

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-04-23 11:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found