Hi, Ken, Thanks for the quick reply. Actually, I want to avoid using "use," because it will get caught if Perl couldn't find the Inline module and terminate my program. So Eric suggested using Inline::import(). My code is as follows (modified after reading your message), but it still can't find the C subroutine. Can you take a look? Thanks!
Steven Here is the error message: Undefined subroutine &main::add_C called at testperl.pl line 19. My perl script: #!/bin/perl BEGIN { eval {require Inline::C}; if ($@) { $noC = 1; } else { $noC = 0; Inline::import(Inline, C => join('', <END>)); } } add_C(1); __END__ __C__ void add_C(int x) { printf("-----------here!..x=%d\n",x); } -----Original Message----- From: Williams, Ken [mailto:[EMAIL PROTECTED] Sent: Thursday, March 25, 2004 2:01 PM To: Wu, Gang (Steven); Eric Wilhelm Cc: [EMAIL PROTECTED] Subject: RE: How do I disable modules in a script > -----Original Message----- > From: Wu, Gang (Steven) [mailto:[EMAIL PROTECTED] > > Hi, Eric, > > Your method needs to have all the C code in the BEGIN block. > What if I > have a rather long C code and I want it to be at the end of > the file? Is there any way? How you construct the string that you pass to the 'use' statement is up to you. The following works if you put your C code in the __DATA__ section: use Inline C => join('', <DATA>); -Ken