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

Re: Mulit-Platform use case

by RyuMaou (Deacon)
on Mar 19, 2009 at 19:30 UTC ( #751843=note: print w/ replies, xml ) Need Help??


in reply to Mulit-Platform use case

About two four years ago (wow, the time flies!), I was messing around with a script I wanted to run on a bunch of different systems, so I was doing a lot of OS detection. I just modified that slightly to check the code and the following syntax worked just fine:

if ($^O eq "MSWin32") { use Win32; }

I'll throw the rest of the OS detection craziness into my scratchpad, if anyone is interested in it.


Comment on Re: Mulit-Platform use case
Download Code
Re^2: Mulit-Platform use case
by cdarke (Prior) on Mar 19, 2009 at 20:23 UTC
    That will not work stand-alone because (as moritz said) use is executed at compile time. Even if placed in a BEGIN block.
    For example, on Windows:
    use strict; use warnings; if ($^O ne "MSWin32") { use POSIX; } local $, = "\n"; print keys %INC
    shows that POSIX.pm is loaded.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2015-07-04 02:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls