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?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|