Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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 about the Monastery: (5)
As of 2014-11-29 02:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (203 votes), past polls