----- Original Message ----- From: "Patrick LeBoutillier" <patrick.leboutill...@gmail.com>
To: "Sisyphus" <sisyph...@optusnet.com.au>
Cc: "inline" <inline@perl.org>
Sent: Thursday, January 27, 2011 2:37 AM
Subject: Re: require an inline script that contains DATA section


Rob,

As is you can't because Inline uses an INIT block to kickstart the
reading from the DATA handle, and INIT blocks are not run when you
"require" a file.

You need to modify data.pl in two ways for this to work:

1) replace __END__ by __DATA__ (I think __END__ works only in the main script)

2) Kickstart the Inline DATA processing manually by adding
Inline->init() as the first line of your script.

Here is a version that worked for me:

use warnings;
use Inline C;
Inline->init() ;

print multiply(3, 7), "\n"; # line 5

1;

__DATA__

__C__

int multiply(int x, int y) {
 return x * y;
}

Thanks Patrick.

That's precisely what I was looking for.

Cheers,
Rob

Reply via email to