Re: POD addition for Inline::CPP

[email protected] ("Sisyphus")
Newsgroups perl.inline
Message-ID <DE463B7BED144297B2B2E665B6D0FFD8@desktop2>
----- Original Message ----- 
From: "David Oswald"

>
> To start, we'll create a simple module, and put it in
> C<~/project/lib/> as C<MyModule.pm>:
>
>    package MyModule;
>
>    use Inline CPP => 'DATA';
>    use parent 'Exporter';
>    our @EXPORT = 'greet';
>
>    # Nothing to see here.
>
>    1;
>
>    __DATA__
>    __CPP__
>
>    void greet() {
>      std::cout << "Hello world\n";
>    }
>
> Now we'll create a script and put it in C<~/project/bin/> as 
> C<myscript.pl>:
>
>    use FindBin;
>    use lib "$FindBin::Bin/../lib";
>
>    use MyModule;
>
>    greet();
>
>
> =head2 What happens now?
>
> The first time you run C<myscript.pl>, Inline::CPP will build the C++
> code from MyModule.pm, and assuming the build succeeds, it will be
> cached so that on future runs there is no need to recompile unless the
> C++ code is altered in some way.

If you have scripts in *different* directories, each of which uses MyModule, 
then I think compilation will occur for the first running of *each* of those 
scripts.
This could be avoided by specifying the fully qualified path to a designated 
build directory, using the DIRECTORY config option (in MyModule.pm).

Can't think of any other problems with your proposal.

Cheers,
Rob
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.