use strict; my $OS_TYPE = $^O eq 'MSWin32' ? 'win' : ($^O eq 'nonstop_kernel' ? 'nsk' : 'unix'); 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" } sub xplatform_fn { return &{$XPlat::{$OS_TYPE."_fn"}} } xplatform_fn();