http://qs1969.pair.com?node_id=228825

timbu has asked for the wisdom of the Perl Monks concerning the following question:

I have a script that I would like to use across several UNIX platforms + Win32. I would like to use the same source on both. The problem is code like this.

sub readConfig { if ($^O eq "MSWin32") { use Win32::TieRegistry; # read some stuff from registry } else { open (CONFIG, '/etc/something') or die "$!:Blech\n"; # read some config info in } return "something important"; }

That work's but on Solaris you need to have the Win32 module installed. I have dreamed up the following options.

1) Use C preprocessor and #ifdef out the win32 code as a build step, when packaging the code. Blech.

2) Create a Win32::TieRegistry module with a "1;" on non Win32 platforms.

3) ?

Any ideas?