>>>>> "MS" == Mark Shelor <> writes:
MS> Basically, I want to set things up such that the C-language XSUBs are
MS> automatically used if the build platform has a C compiler. Otherwise,
MS> the pure Perl versions of the routines would be installed.
MS> Could anyone point me to relevant examples or how-to documentation?
i do this exact thing in stem. it is very simple. you make the C and
perl versions into sibling classes and have a wrapper class above
them. something like this:
Foo.pm
Foo/Perl.pm
Foo/C.pm
the user always creates a Foo but inside that it tries to load Foo/C.pm
and it uses that if it can. else it tries to load Foo/Perl.pm and that
had better succeed or you die.
here is my code that does this. it tries to load the event loop you
request which is normally the c module Event.pm and falls back to my
Perl event loop. on winblows it always uses the Perl one since Event.pm
is unix specific.
the can't locate a module is the only error allowed. then it
will do the forced load of Perl.pm
my $loop_type = $Stem::Vars::Env{ 'event_loop' } ||
($^O =~ /win32/i ? 'perl' : 'event' );
my $loop_class = $loop_to_class{ $loop_type } || 'Stem::Event:

erl' ;
unless ( eval "require $loop_class" ) {
die "can't load $loop_class: $@" if $@ && $@ !~ /locate/ ;
eval 'require Stem::Event:

erl' ;
die "can't load default event loop Stem::Event:

erl $@" if $@ ;
}
uri
--
Uri Guttman ------
--------
http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ----------------------------
http://jobs.perl.org