http://www.perlmonks.org?node_id=156448


in reply to Re: Runtime module use and sub definitions
in thread Runtime module use and sub definitions

I like that much better than the string eval. I tried this and it seems to work fine:
#!/usr/bin/perl use strict; use warnings; if ($^O eq 'MSWin32') { eval { require Win32::OLE; Win32::OLE->import; }; *bar = sub { print "Win32\n" }; } else { *bar = sub { print "Not Win32\n" }; } #later in the program... #we don't care what OS is running -- implementation details are hidden bar();