package XPlat; use strict; my $OS_TYPE = $^O eq 'MSWin32' ? 'win' : ($^O eq 'nonstop_kernel' ? 'nsk' : 'unix'); push @ISA, "XPlat::$OS_TYPE"; sub XPlat::win::fn { print "windows version of function\n" } sub XPlat::nsk::fn { print "nsk version of function\n" } sub XPlat::unix::fn { print "unix version of function\n" } package main; XPlat->fn(); # calls function in whichever package is appropriate