Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Writing portable code

by tobyink (Abbot)
on Mar 08, 2013 at 09:51 UTC ( #1022369=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    BEGIN {
      $^O eq 'Win32'
        ? eval q[ sub f { ... } ]  # Win32 implementation
        : eval q[ sub f { ... } ]  # Linux implementation
    };
    
  2. or download this
    BEGIN { eval($^O eq 'Win32' ? <<'WIN32' : <<'LINUX') };
    sub f { print "f-w\n" }
    ...
    sub f { print "f-l\n" }
    sub g { print "g-l\n" }
    LINUX
    
  3. or download this
    use constant BROKEN_FORK_IMPLEMENTATION => ($^O eq 'Win32');
    
    ...
          ...;
       }
    }
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2014-10-22 02:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (112 votes), past polls