in reply to Re^2: Writing portable code
in thread Writing portable code
Even thinking about having a few unused entries in the symbol table is a ridiculous micro-optimisation.
If you want to keep the code clean and in one file, then I suggest something like this ...
use Devel::CheckOS; setup_for_platform(); ... application code goes here ... # decide what platform-specific code to use sub setup_for_platform { if(os_is('MicrosoftWindows')) { *do_stuff = \&do_stuff_for_windows; } elsif(os_is('Unix')) { *do_stuff = \&do_stuff_for_unix; } else { die("Don't know about $^O\n"); } } # platform-specific function implementations sub do_stuff_for_unix { ... } sub do_stuff_for_windows { ... }
|
---|
In Section
Seekers of Perl Wisdom