[EMAIL PROTECTED] wrote:
> I have a Perl application that should work on both Windows and Linux.
> On Windows I use some of the Windows-specific modules, e.g.
> "Win32API::File". So my code have things like:
Check
perldoc perlvar
namely the $^O variable that holds your OS name e.g:
C:\>perl -e "print $^O"
MSWin32
also while use statements do happen at compile time, meaning you cannot
conditionally include stuff, you can always use require instead.
perldoc -f use
Quote:
It is exactly equivalent to
BEGIN { require Module; import Module LIST; }
End quote.
You can also check out do and import in perlfunc.
Another tip, see how it is done in modules, e.g. from:
C:\Perl\lib\File\Spec.pm
my %module = (MacOS => 'Mac',
MSWin32 => 'Win32',
os2 => 'OS2',
VMS => 'VMS',
epoc => 'Epoc',
NetWare => 'Win32', # Yes, File::Spec::Win32 works on NetWare.
symbian => 'Win32', # Yes, File::Spec::Win32 works on symbian.
dos => 'OS2', # Yes, File::Spec::OS2 works on DJGPP.
cygwin => 'Cygwin');
my $module = $module{$^O} || 'Unix';
require "File/Spec/$module.pm";
@ISA = ("File::Spec::$module");
etc...
Hope this helps.
BTW: this is the first time I'm viewing the File::Spec source. reading
bits of interesting code is a great way to learn.
--
With kind regards Veli-Pekka Tätilä ([EMAIL PROTECTED])
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs