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?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: cross platform scripts
by rob_au (Abbot) on Jan 21, 2003 at 21:16 UTC | |
by timbu (Novice) on Jan 21, 2003 at 21:27 UTC | |
by John M. Dlugosz (Monsignor) on Jan 21, 2003 at 22:55 UTC | |
Re: cross platform scripts
by Mr. Muskrat (Canon) on Jan 21, 2003 at 20:29 UTC | |
by Anonymous Monk on Jan 21, 2003 at 22:45 UTC | |
Re: cross platform scripts
by zakb (Pilgrim) on Jan 21, 2003 at 20:34 UTC | |
Re: cross platform scripts
by bart (Canon) on Jan 23, 2003 at 03:59 UTC |
Back to
Seekers of Perl Wisdom