http://www.perlmonks.org?node_id=923821


in reply to code that runs (and works) on both Linux and Win32

Perosnally I use the if pragma for loading modules. I put platform specific code into subroutines, and call via a dispatch table:
# simplified my %g_dt = (MsWin32 => \&WinStuff, linux => \&LinuxStuff, # and so on ); ... # The call $g_dt{$^O}->(args);
(With suitable checks at load time to ensure $^O is a key to %g_dt)