Hi, there,
I have a question regarding inclusion of the Inline module. How do I enable or disable the module in my script depending on occasions? My case is as follows. My script uses embedded C code, and thus I need to put "use Inline::C" in my script. However, *some* users of my script might not have the Inline module installed, and I wonder in that case how I can disable the "use Inline::C" statement. In other words, I want something like the following pseudo code:
If have Inline module, use Inline::C; Else, do nothing.
Is there anything in Perl that can do this?
Thanks!
Steven
use warnings;
BEGIN { eval{require Inline::C}; if($@) { print "No Inline::C here\n"; # do whatever you want exit; } }
use Inline C => <<'EOC';
void got_it() { printf("We have Inline::C\n"); }
EOC
got_it();
__END__
Seems to work as you want. As it is it prints "We have Inline::C". If I change all occurrences of 'Inline::C' (and 'Inline C') to 'Inline::D' (and 'Inline D') then it prints "No Inline::D here" and quietly exits.
Cheers, Rob
--
Any emails containing attachments will be deleted from my ISP's mail server before I even get to see them. If you wish to email me an attachment, please provide advance warning so that I can make the necessary arrangements.