in reply to Using a 'package' as a 'module', and choosing at runtime?

I'd put the various packages in different files. For instance, the file mac.pm:
package mac; use strict; use warnings; use Exporter (); our @EXPORT = qw /get_answer/; our @ISA = qw /Exporter/; sub get_answer { "mac"; } 1; __END__

And then the main program:

#!/usr/bin/perl use strict; use warnings; BEGIN { if ( $^O =~ /dar/ ) { require mac; mac -> import; } elsif ( $^O =~ /sol/ ) { require sun; sun -> import; } elsif ( $^O =~ /aix/ ) { require aix; aix -> import; } else { die "unknown os." } }; print "answer is " . get_answer () . "\n"; __END__

Abigail