I have Perl on Mac, Windows and Ubuntu. How can I tell from within the script which one is which? Thanks in advance.
Edit: I was asked what I am doi
Look inside the source for File::Spec to see how it loads the right delegate based on the operating system. :)
File::Spec has a separate Perl module file for each OS. File::Spec::Win32, File::Spec::OS2, etc...
It checks the operating system and will load the appropriate .pm file at runtime based on OS.
# From the source code of File::Spec
my %module = (
MSWin32 => 'Win32',
os2 => 'OS2',
VMS => 'VMS',
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',
amigaos => 'AmigaOS');
my $module = $module{$^O} || 'Unix';
require "File/Spec/$module.pm";
our @ISA = ("File::Spec::$module");