Fellow Monks, I have a script which uses Inline::C to pull in several files. Currently it looks like this.
use warnings;
use strict;
use File::Spec;
use File::Basename;
my $inlineCFile;
my $inlineCFile2;
my $relSourcePath;
my $inlineBuildDir;
my $libDir;
my $incDir;
BEGIN {
$relSourcePath = File::Spec->rel2abs(dirname($0));
$inlineCFile = File::Spec->catfile($relSourcePath, "foo.c");
$inlineCFile2 = File::Spec->catfile($relSourcePath, "bar.c");
my @dirs = ();
push @dirs, $relSourcePath;
push @dirs, ".Inline";
$inlineBuildDir = File::Spec->catdir(@dirs);
pop @dirs;
push @dirs, "lib";
$libDir = File::Spec->catdir(@dirs);
pop @dirs;
push @dirs, "include";
$incDir = File::Spec->catdir(@dirs);
}
use Inline (
C => Config =>
LIBS => "-L$libDir",
INC => "-I$incDir",
DIRECTORY => $inlineBuildDir,
);
use Inline C => $inlineCFile;
use Inline C => $inlineCFile2;
HelloFoo();
HelloBar();
where, for the sake of this question, foo.c is
void HelloFoo()
{
printf("hello from foo\n");
}
and bar.c is
void HelloBar()
{
printf("hello from bar\n");
}
Now, let's say that I want to pull in many more such Inline::C files into my script. Is there a better way than the individual scalar definition for each C file inside the BEGIN block followed by the individual
use Inline::C => $myFile?